diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 781d6d0..1acbd0d 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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 ==="