Add AZ schema migration script and health check

This commit is contained in:
Kelly
2025-12-02 10:40:06 -07:00
parent 8c83bd451a
commit 7a76a29acb
2 changed files with 32 additions and 1 deletions

View File

@@ -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",

View 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();