Files
blinds_express/db/migrate.js
Aditya Pulipaka 7da8bda5eb
All checks were successful
Deploy to Server / deploy (push) Successful in 18s
end-to-end CI to match containerization on rest of adipu_server
2026-05-05 00:10:39 +00:00

24 lines
664 B
JavaScript

// Idempotent schema migration. Mirrors LabWise's server/src/db/migrate.ts —
// reads schema.sql and runs it through the same env-driven pg config the app
// uses, then exits. Compose's CMD chains this before `node index.js`.
const fs = require('fs');
const path = require('path');
const { Pool } = require('pg');
async function migrate() {
const sql = fs.readFileSync(path.join(__dirname, 'schema.sql'), 'utf-8');
const pool = new Pool();
try {
await pool.query(sql);
console.log('[migrate] schema applied');
} finally {
await pool.end();
}
}
migrate().catch((err) => {
console.error('[migrate] failed:', err);
process.exit(1);
});