import { drizzle } from 'drizzle-orm/postgres-js'; import { migrate } from 'drizzle-orm/postgres-js/migrator'; import postgres from 'postgres'; import * as dotenv from 'dotenv'; dotenv.config({ path: '.env.local' }); const runMigration = async () => { const connectionString = process.env.DIRECT_URL; if (!connectionString) { throw new Error('DIRECT_URL environment variable is not set'); } console.log('🔄 Running database migrations...'); const sql = postgres(connectionString, { max: 1 }); const db = drizzle(sql); await migrate(db, { migrationsFolder: './drizzle' }); await sql.end(); console.log('✅ Migrations completed successfully'); }; runMigration().catch((err) => { console.error('❌ Migration failed:', err); process.exit(1); });