end-to-end CI to match containerization on rest of adipu_server
All checks were successful
Deploy to Server / deploy (push) Successful in 18s
All checks were successful
Deploy to Server / deploy (push) Successful in 18s
This commit is contained in:
23
db/migrate.js
Normal file
23
db/migrate.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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);
|
||||
});
|
||||
Reference in New Issue
Block a user