Skip to content

fix(ci): run migrations in the API deploy, before the code that needs them (Sentry #7645807976) - #154

Merged
stewartjarod merged 2 commits into
mainfrom
fix/sentry-7645807976-deploy-migrations
Aug 1, 2026
Merged

fix(ci): run migrations in the API deploy, before the code that needs them (Sentry #7645807976)#154
stewartjarod merged 2 commits into
mainfrom
fix/sentry-7645807976-deploy-migrations

Conversation

@stewartjarod

Copy link
Copy Markdown
Contributor

Summary

Auto-detected via Sentry issue #7645807976column batch_send.paused_at does not exist, 111 events, ongoing.

Root cause is not the reaper. deploy-api.yml has never had a migration step, so every schema change reached production only if someone remembered to run db:migrate by hand. Commit 2b7a06c8 added batch_send.paused_at, migration 0073_dazzling_puma, and the runBroadcastReaper query that reads the column — all in one commit. The Lambda deployed, the migration did not, and the reaper has thrown on every run since.

Fix. Migrate before sst deploy, for the reason 405063c5 already established for the selfhost path: sst deploy publishes each Lambda's new code the moment that function updates, well before the command returns, so migrating afterwards still leaves a window where new code runs against the old schema. That commit's own message names batch_send.paused_at as the motivating case — it landed for selfhost on Jul 31 and the same bug hit hosted production the next morning.

Failing this way round is also the better failure: a migration that dies leaves old code on the old schema, which works.

⚠️ This PR does not fix production

The production database is still missing 0073_dazzling_puma and the reaper is still throwing. Merging this only prevents recurrence. 0073 has to be applied out of band — this PR makes the next deploy carry its migrations, not this one.

Sentry Context

  • Error: error: column batch_send.paused_at does not exist (wrapped as Error: Failed query: select …)
  • Occurrences: 111 | Affected users: 0 (background worker)
  • First seen: 2026-08-01T05:34Z | Last seen: 2026-08-01T14:38Z
  • Entry point: runBroadcastReaper

Test plan

  • Regression test added at baseline/deploy-api-workflow.test.ts (runs in CI via pnpm test:architecture)
  • Red→green: all 3 assertions failed before the fix, pass after
  • Mutation-tested — moving the migrate step after sst deploy fails the ordering assertion
  • Workflow YAML parses; migrate is step 7, deploy step 8
  • Biome clean, tsc clean, 34/34 baseline tests pass
  • Confirm secrets.DATABASE_URL in the production environment permits DDL

Note on scope

The test asserts workflow ordering rather than reproducing the SQL error, because the defect is a missing pipeline step — the repo's schema and migration were always correct. This mirrors the existing selfhost-deploy-workflow.test.ts precedent.

Generated by sentry-autofix

stewartjarod and others added 2 commits August 1, 2026 11:29
… them

deploy-api.yml had no migration step at all, so every schema change reached
production only if someone remembered to run db:migrate by hand. batch_send
.paused_at is what happened when nobody did: the column and the broadcast-reaper
query that reads it shipped in the same commit (2b7a06c), the Lambda went live,
and the reaper threw `column batch_send.paused_at does not exist` on every run
against production -- 111 events before this was noticed.

Migrating before deploying rather than after, for the reason 405063c already
established for selfhost: `sst deploy` publishes each Lambda's new code the
moment that function updates, well before the command returns, so migrating
afterwards still leaves a window where new code runs against the old schema.

Failing this way round is also the better failure -- a migration that dies
leaves old code on the old schema, which works. Safe because migrations are
expected to be backward compatible; a migration that removes or renames still
has to be split expand/contract across two releases either way.

Does not fix the currently-broken production database, which is still missing
0073_dazzling_puma and needs it applied out of band.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PAoM6kmDzrf5BxmbXn1Z51
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
wraps-web Building Building Preview Aug 1, 2026 5:33pm
wraps-website Ready Ready Preview Aug 1, 2026 5:33pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant