fix(deploy): move inline node -e scripts into separate files to fix shell quoting errors
Deploy to route.crispygoat.com / deploy (push) Successful in 4m16s
Deploy to route.crispygoat.com / deploy (push) Successful in 4m16s
The inline node -e '...' blocks inside the YAML run: block had shell
quoting conflicts (nested parens, single-quote escapes) that caused
act/local tooling to fail with 'syntax error near unexpected token ('.
Split into two dedicated scripts:
- scripts/preflight-check.js — neon_auth schema check + 0001_init.sql tracking repair
- scripts/postflight-check.js — admin_users table verification after migrations
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Post-migration verification.
|
||||
* Called by .gitea/workflows/deploy.yml after npm run migrate:one.
|
||||
* Confirms critical table admin_users is queryable.
|
||||
*/
|
||||
const { Client } = require("pg");
|
||||
|
||||
async function main() {
|
||||
const url = process.env.DATABASE_URL;
|
||||
if (!url) {
|
||||
console.error("No DATABASE_URL");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const c = new Client({ connectionString: url });
|
||||
await c.connect();
|
||||
|
||||
try {
|
||||
console.log("=== Post-migration verification: critical table admin_users must exist ===");
|
||||
await c.query("SELECT 1 FROM admin_users LIMIT 1");
|
||||
console.log("✓ admin_users table exists and is queryable");
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
console.error("✗ FATAL: admin_users relation missing after migrate:", e.message);
|
||||
console.error("The deploy cannot continue. The secret DATABASE_URL must have had db/migrations/0001_init.sql applied successfully.");
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await c.end();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user