Spaces:
Runtime error
Runtime error
File size: 785 Bytes
ceb943f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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);
});
|