Spaces:
Runtime error
Runtime error
| 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); | |
| }); | |