Commit 7b7979d
fix(db): hotfix prod schema drift — add is_premium, premium_price_cents, listed_in_marketplace
Production was returning 500s on /api/tools, /marketplace/trending,
/api/v1/discover, and /api/templates/* routes with errors like
'column "is_premium" of relation "tools" does not exist' and
'column "listed_in_marketplace" does not exist'.
Root cause:
1. is_premium + premium_price_cents were added to schema.ts (lines
124-125) without a corresponding migration ever being generated.
Three API routes referenced the columns but no .sql migration
added them.
2. Migration 0001_listed_in_marketplace.sql was generated and
recorded in meta/_journal.json but never applied to prod —
Vercel does not auto-run drizzle migrations on deploy and no
manual `drizzle-kit migrate` was ever run against prod
DATABASE_URL.
Hotfix applied to prod via psql (idempotent ADD COLUMN IF NOT
EXISTS) on 2026-04-29:
- tools.listed_in_marketplace boolean NOT NULL DEFAULT true
- tools.is_premium boolean NOT NULL DEFAULT false
- tools.premium_price_cents integer
- UPDATE tools SET listed_in_marketplace = false WHERE status = 'draft'
(1 row affected; 1,460 total rows in table)
Post-hotfix verification:
- /api/tools: 500 → 401 (auth-gated, reaches gate without DB error)
- /marketplace/trending: 500 → 200
- /api/v1/discover: 500 → 200
- /sitemap.xml: 200 (was sometimes 500 with ENOENT — separate P3)
This file 0008_premium_template_columns.sql is the source-of-truth
record. Idempotent ADD COLUMN IF NOT EXISTS makes it safe to re-run
through drizzle-kit migrate on a fresh environment.
Out of scope (separate triage card needed):
- drizzle.__drizzle_migrations table is empty in prod — Drizzle has
zero record of any migration applied even though base schema is
provisioned. Reconciling the journal with prod state requires
auditing what's actually in the prod DB vs what the migration
files would create.
- Migrations 0002-0007 (mcp_shadow_index, ledger_*, processed_
webhook_events, chargeback_alerts) exist as files but have not
been applied to prod and are not in meta/_journal.json. Apply
selectively after auditing each one — some create new tables
that may already exist in some other form.
Refs: P0-prod-schema-drift, blocks PR #3 merge
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 70aa130 commit 7b7979d
2 files changed
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
0 commit comments