dvijaykrishnan's picture
Deployment fix for HF
ceb943f
Raw
History Blame Contribute Delete
785 Bytes
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);
});