fix: add Bun database migration runner

This commit is contained in:
MythEclipse
2026-05-18 08:25:24 +07:00
parent 91986d1d51
commit 2c1c5ad638
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
import postgres from 'postgres';
import { config } from '../env';
import logger from '../utils/logger';
const schemaSql = await Bun.file('schema.sql').text();
const sql = postgres(config.databaseUrl, { max: 1 });
try {
await sql.unsafe(schemaSql);
logger.info('Database migration completed');
} catch (error: any) {
logger.error('Database migration failed', { error: error.message });
process.exitCode = 1;
} finally {
await sql.end();
}