{
  "id": 12237358,
  "title": "Migration says applied, but production says column does not exist",
  "url": "https://urgent.news/2026/10/05/migration-says-applied-but-production-says-column-does-not-exist",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-05T21:57:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gemmein/migration-says-applied-but-production-says-column-does-not-exist-7e8"
  },
  "original_language": "en",
  "account": "A migration issue occurs when a database migration appears successful, but production reveals missing data. Reports show that 6% of public posts from builders whose apps broke during or after launch involve database and data loss. The problem is that the migration tool reports the schema as up to date, even though production shows a missing column. This discrepancy leads to 500 error codes on API routes and broken features.\n\nThe issue stems from the migration tool trusting its history table, rather than checking the actual schema. When a migration is applied using commands like `prisma migrate deploy` or `supabase db push`, the tool marks the migration as applied in a history table. If a subsequent migration fails, the tool will not run any further migrations, as they are assumed to be already applied. Consequently, missing data remains unnoticed until someone manually checks the database.\n\nTo reproduce the issue, one can set up a Docker container with PostgreSQL and create a simple schema with two tables, `tenants` and `events`. Then, apply a migration that moves the `events` table into a tenant-scoped table and drops the original `events` table. Run a SQL query to count the number of rows in the `tenant_events` table, which should return the number of rows inserted.\n\nThe crucial insight is that the migration tool doesn't check for schema drift. It relies solely on the history table to determine if a migration has been applied. This behavior can lead to silent data loss when a migration succeeds but fails in production due to a missing column or another schema issue. To catch this issue early, it's essential to test the live schema against the repository and ensure that migrations are being applied correctly in the production environment.",
  "summary": "We read 3,426 public posts from builders whose apps broke at or after launch, and verified 418 recent cases. Database and data loss is 6% of them. Six verified reports in that data describe the same failure: the deploy succeeded, the migration tool says everything is applied, and production disagrees. From the builder's chair it looks like this. API routes return 500 straight after a deploy, and…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}