Commita358c63unknown_key
fix(deploy): re-add db migration step — was the source of 500s on /settings
fix(deploy): re-add db migration step — was the source of 500s on /settings User reported a 500 on the repo settings page (`/:owner/:repo/settings`). The handler does a `SELECT *` from `repositories`, then reads columns including `is_template` (migration 0022), `is_archived`, and `auto_close_stale_prs` / `auto_close_stale_issues` (migration 0045). If prod's DB hasn't applied any of those, drizzle's SELECT throws and the route 500s. My previous fire-drill deploy script (d8b9606) intentionally skipped `bun run src/db/migrate.ts` to eliminate any silent-fail surface while chasing the AA-loop deploy. Side effect: if the live DB was missing migrations 0046–0054, those stayed missing. Re-adding migrations as STEP 3 (before the systemd restart) so any schema drift catches up. Migrations run after `bun install` (so neon/postgres clients are on disk) and before the BUILD_SHA pin + restart (so the new code doesn't boot against a stale schema). `set -Eeuxo pipefail` still traces every line; if migrate.ts crashes, we'll see exactly which migration fails. After this lands, every future deploy will keep the DB in sync, and the existing 500 on /settings should clear.
1 file changed+13−2a358c6331343255f46a0b1177a699a07981c1e79
1 changed file+13−2
Modified.github/workflows/hetzner-deploy.yml+13−2View fileUnifiedSplit
@@ -178,7 +178,18 @@ jobs:
178178 BUN=/root/.bun/bin/bun
179179 "$BUN" install --frozen-lockfile
180180
181 echo "=== STEP 3: pin BUILD_SHA in systemd drop-in ==="
181 echo "=== STEP 3: run db migrations ==="
182 # Source /etc/gluecron.env so DATABASE_URL is available to
183 # migrate.ts. Hard-fail if any migration errors — the previous
184 # `|| echo WARN` swallowed migration failures and left the DB
185 # out of sync with the schema, which produces 500s on every
186 # page that SELECTs a column added by a missed migration.
187 set -a
188 source /etc/gluecron.env
189 set +a
190 "$BUN" run src/db/migrate.ts
191
192 echo "=== STEP 4: pin BUILD_SHA in systemd drop-in ==="
182193 mkdir -p /etc/systemd/system/gluecron.service.d
183194 cat > /etc/systemd/system/gluecron.service.d/build-sha.conf <<EOF
184195 [Service]
@@ -187,7 +198,7 @@ jobs:
187198 EOF
188199 systemctl daemon-reload
189200
190 echo "=== STEP 4: restart gluecron systemd unit ==="
201 echo "=== STEP 5: restart gluecron systemd unit ==="
191202 systemctl restart gluecron
192203 echo "=== DONE: service restarted with $new_sha ==="
193204
194205