summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-10-30 14:12:49 -0400
committerFrank <[email protected]>2025-10-30 15:10:29 -0400
commit1a8b494055f17d2fced59c0dc00f8364e4d042f3 (patch)
treeacf419f404d8238c78d162a4195d463def4d77a7 /packages/console/core
parent4f02d7d424bef3d5be7a9bb7a592d4f6d326a8a3 (diff)
downloadopencode-1a8b494055f17d2fced59c0dc00f8364e4d042f3.tar.gz
opencode-1a8b494055f17d2fced59c0dc00f8364e4d042f3.zip
wip: zen
Diffstat (limited to 'packages/console/core')
-rw-r--r--packages/console/core/script/lookup-user.ts33
-rw-r--r--packages/console/core/script/reset-db.ts22
2 files changed, 48 insertions, 7 deletions
diff --git a/packages/console/core/script/lookup-user.ts b/packages/console/core/script/lookup-user.ts
new file mode 100644
index 000000000..af9bcc3a1
--- /dev/null
+++ b/packages/console/core/script/lookup-user.ts
@@ -0,0 +1,33 @@
+import { Database, eq } from "../src/drizzle/index.js"
+import { AuthTable } from "../src/schema/auth.sql"
+
+// get input from command line
+const email = process.argv[2]
+if (!email) {
+ console.error("Usage: bun lookup-user.ts <email>")
+ process.exit(1)
+}
+
+const authData = await printTable("Auth", (tx) =>
+ tx.select().from(AuthTable).where(eq(AuthTable.subject, email)),
+)
+if (authData.length === 0) {
+ console.error("User not found")
+ process.exit(1)
+}
+
+await printTable("Auth", (tx) =>
+ tx.select().from(AuthTable).where(eq(AuthTable.accountID, authData[0].accountID)),
+)
+
+function printTable(
+ title: string,
+ callback: (tx: Database.TxOrDb) => Promise<any[]>,
+): Promise<any[]> {
+ return Database.use(async (tx) => {
+ const data = await callback(tx)
+ console.log(`== ${title} ==`)
+ console.table(data)
+ return data
+ })
+}
diff --git a/packages/console/core/script/reset-db.ts b/packages/console/core/script/reset-db.ts
index 96ecf14e7..bd00e1962 100644
--- a/packages/console/core/script/reset-db.ts
+++ b/packages/console/core/script/reset-db.ts
@@ -1,13 +1,21 @@
import { Resource } from "@opencode-ai/console-resource"
-import { Database } from "@opencode-ai/console-core/drizzle/index.js"
-import { UserTable } from "@opencode-ai/console-core/schema/user.sql.js"
-import { AccountTable } from "@opencode-ai/console-core/schema/account.sql.js"
-import { WorkspaceTable } from "@opencode-ai/console-core/schema/workspace.sql.js"
-import { BillingTable, PaymentTable, UsageTable } from "@opencode-ai/console-core/schema/billing.sql.js"
-import { KeyTable } from "@opencode-ai/console-core/schema/key.sql.js"
+import { Database } from "../src/drizzle/index.js"
+import { UserTable } from "../src/schema/user.sql.js"
+import { AccountTable } from "../src/schema/account.sql.js"
+import { WorkspaceTable } from "../src/schema/workspace.sql.js"
+import { BillingTable, PaymentTable, UsageTable } from "../src/schema/billing.sql.js"
+import { KeyTable } from "../src/schema/key.sql.js"
if (Resource.App.stage !== "frank") throw new Error("This script is only for frank")
-for (const table of [AccountTable, BillingTable, KeyTable, PaymentTable, UsageTable, UserTable, WorkspaceTable]) {
+for (const table of [
+ AccountTable,
+ BillingTable,
+ KeyTable,
+ PaymentTable,
+ UsageTable,
+ UserTable,
+ WorkspaceTable,
+]) {
await Database.use((tx) => tx.delete(table))
}