Add AZ schema migration script and health check
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"migrate": "tsx src/db/migrate.ts",
|
||||
"seed": "tsx src/db/seed.ts"
|
||||
"seed": "tsx src/db/seed.ts",
|
||||
"migrate:az": "tsx src/dutchie-az/db/migrate.ts",
|
||||
"health:az": "tsx -e \"import { healthCheck } from './src/dutchie-az/db/connection'; (async()=>{ const ok=await healthCheck(); console.log(ok?'AZ DB healthy':'AZ DB NOT reachable'); process.exit(ok?0:1); })();\""
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.2",
|
||||
|
||||
29
backend/src/dutchie-az/db/migrate.ts
Normal file
29
backend/src/dutchie-az/db/migrate.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Dutchie AZ Schema Bootstrap
|
||||
*
|
||||
* Run this to create/update the dutchie_az tables (dutchie_products, dutchie_product_snapshots, etc.)
|
||||
* in the AZ pipeline database. This is separate from the legacy schema.
|
||||
*
|
||||
* Usage:
|
||||
* TS_NODE_TRANSPILE_ONLY=1 npx ts-node src/dutchie-az/db/migrate.ts
|
||||
* or (after build)
|
||||
* node dist/dutchie-az/db/migrate.js
|
||||
*/
|
||||
|
||||
import { createSchema } from './schema';
|
||||
import { closePool } from './connection';
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log('[DutchieAZ] Running schema migration...');
|
||||
await createSchema();
|
||||
console.log('[DutchieAZ] Schema migration complete.');
|
||||
} catch (err: any) {
|
||||
console.error('[DutchieAZ] Schema migration failed:', err.message);
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
await closePool();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user