You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(db): drop orphaned import_* columns from user_table_definitions (#7188)
Contract phase for the table-jobs cutover. Migration 0233 moved import job
state into table_jobs and removed every application read and write, but
deliberately left the five import_* columns in place so the then-deployed app
version kept working across blue/green cutover. The follow-up drop was never
written.
The columns have been invisible to Drizzle ever since: the model lost them in
the same release, so every meta snapshot from 0233 onward already omits them
and `drizzle-kit generate` reports no diff. They exist only physically, which
is why this is a custom migration.
-- Custom SQL migration file, put your code below! --
2
+
3
+
-- Contract of #4915 (migration 0233), which moved import job state out of these five
4
+
-- `user_table_definitions` columns into `table_jobs` and removed every application read
5
+
-- and write in the same release. 0233 deferred the drop on purpose so the then-deployed
6
+
-- app version could keep using the columns across blue/green cutover; that deploy drained
7
+
-- long ago (0233 is 77 migrations back). The deferral was never recorded with a
8
+
-- `contract-pending` marker, which is why it went unnoticed.
9
+
--
10
+
-- This is a custom migration because Drizzle cannot generate it: #4915 removed the fields
11
+
-- from `schema.ts` in the same release, so every meta snapshot from 0233 onward already
12
+
-- omits them. `drizzle-kit generate` diffs schema-vs-snapshot, never schema-vs-database,
13
+
-- and reports "No schema changes, nothing to migrate" — the columns exist only physically.
14
+
--
15
+
-- Verified before writing: zero references to any of the five names (snake_case or
16
+
-- camelCase) anywhere outside packages/db/migrations, and in production all five are empty
17
+
-- across all 42,394 `user_table_definitions` rows.
18
+
--
19
+
-- One statement, not five: each ALTER takes its own ACCESS EXCLUSIVE lock on a write-hot
20
+
-- relation, and the runner retries the whole file on lock_timeout (5s, 8 attempts). A single
21
+
-- statement means one lock acquisition and no partially-dropped state between retries. Each
22
+
-- clause is IF EXISTS so the replay is a no-op. No CASCADE on purpose — nothing depends on
23
+
-- these columns (verified: no index, constraint, view, rule, trigger, function, publication,
24
+
-- or generated column references them in production), so if that ever changed this would
25
+
-- fail loudly instead of silently dropping the dependent object.
26
+
27
+
-- migration-safe: contract of #4915 — the last readers/writers were removed there and 0233 backfilled the data into table_jobs; 0 refs remain anywhere in apps/ or packages/, and all five columns are empty across all 42,394 production rows
0 commit comments