Add auto-migration on server startup

Run Drizzle migrations before seeding admin user so tables exist
on fresh database. Migration files generated from current schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 19:41:10 -04:00
parent a061337d6f
commit 066c3310ff
5 changed files with 561 additions and 0 deletions
+2
View File
@@ -6,6 +6,7 @@ import { auth } from './routes/auth';
import { savesRouter } from './routes/saves';
import { leaderboardRouter } from './routes/leaderboard';
import { invitesRouter } from './routes/invites';
import { runMigrations } from './db';
import { seedAdmin } from './db/seed';
if (!process.env.JWT_SECRET) {
@@ -40,6 +41,7 @@ const port = Number(process.env.PORT) || 3001;
console.log(`AI Tycoon API server starting on port ${port}...`);
await runMigrations();
await seedAdmin();
serve({ fetch: app.fetch, port });