fix(deploy): add explicit pre-flight check for neon_auth schema before running migrations (better error than raw 3F000 from 0001_init.sql)

This commit is contained in:
Tyler
2026-06-09 15:50:53 -06:00
parent 91ba7b5c5c
commit 0db1609c89
+22
View File
@@ -25,6 +25,28 @@ jobs:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
set -e
echo "=== Pre-flight: checking for neon_auth schema (required by 0001_init.sql for FKs to neon_auth.user and related RPCs) ==="
node -e '
const { Client } = require("pg");
const url = process.env.DATABASE_URL;
if (!url) { console.error("No DATABASE_URL"); process.exit(1); }
const c = new Client({ connectionString: url });
c.connect()
.then(() => c.query("SELECT 1 FROM information_schema.schemata WHERE schema_name = \'neon_auth\'"))
.then(res => {
if (res.rows.length === 0) {
console.error("✗ FATAL: neon_auth schema does not exist in the target database.");
console.error("Enable Neon Auth on the Neon project/branch that this DATABASE_URL points to first.");
console.error("Run: neonctl neon-auth (or equivalent) against the correct Neon branch.");
console.error("The neon_auth schema is created by Neon Auth and is a prerequisite for 0001_init.sql.");
process.exit(1);
}
console.log("✓ neon_auth schema exists");
return c.end();
})
.then(() => process.exit(0))
.catch(e => { console.error("Pre-flight check failed:", e.message); process.exit(1); });
'
echo "=== Running migrations against DATABASE_URL (masked value for logs) ==="
npm run migrate:one
echo "=== Post-migration verification: critical table admin_users must exist ==="