diff --git a/backend/package.json b/backend/package.json index 9706a1d0..424312ce 100755 --- a/backend/package.json +++ b/backend/package.json @@ -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", diff --git a/backend/src/dutchie-az/db/migrate.ts b/backend/src/dutchie-az/db/migrate.ts new file mode 100644 index 00000000..2055463c --- /dev/null +++ b/backend/src/dutchie-az/db/migrate.ts @@ -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();