From 9c1e11d2e861f140dc6c3cc2cf4f46d1106aee52 Mon Sep 17 00:00:00 2001 From: Rolf Date: Wed, 18 Mar 2026 18:45:30 +0100 Subject: [PATCH] whatever... --- instrumentation.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/instrumentation.ts b/instrumentation.ts index 66a7620..30dca4b 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -20,8 +20,29 @@ export async function register() { const client = postgres(process.env.DATABASE_URL!, { max: 1, connect_timeout: 10 }) const db = drizzle(client) await migrate(db, { migrationsFolder: './lib/db/migrations' }) - await client.end() console.log('[migrations] Done') + + // Seed admin user from ADMIN_EMAIL if not already present + const adminEmail = process.env.ADMIN_EMAIL + if (adminEmail) { + const { user } = await import('./lib/db/schema') + const { eq } = await import('drizzle-orm') + const existing = await db.select({ id: user.id }).from(user).where(eq(user.email, adminEmail)).limit(1) + if (existing.length === 0) { + const { default: crypto } = await import('crypto') + await db.insert(user).values({ + id: crypto.randomUUID(), + email: adminEmail, + name: adminEmail.split('@')[0], + emailVerified: true, + createdAt: new Date(), + updatedAt: new Date(), + }) + console.log('[seed] Admin user created:', adminEmail) + } + } + + await client.end() } catch (err) { console.error('[migrations] Failed:', err) }