Skip to content

chore(db): drop orphaned import_* columns from user_table_definitions - #7188

Merged
waleedlatif1 merged 1 commit into
stagingfrom
investigate/table-col-count
Aug 28, 2026
Merged

chore(db): drop orphaned import_* columns from user_table_definitions#7188
waleedlatif1 merged 1 commit into
stagingfrom
investigate/table-col-count

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Drops the five orphaned import_* columns from user_table_definitionsimport_status, import_id, import_error, import_rows_processed, import_started_at
  • This is the contract phase of the table-jobs cutover. Migration 0233 moved import job state into table_jobs and removed every application read and write, but deliberately left the columns in place so the then-deployed app version kept working across blue/green cutover. The follow-up drop was never written, and no contract-pending marker was left to track it
  • 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
  • schema.ts is intentionally untouched — it has been correct since the cutover; only the database was stale

Type of Change

  • Chore / cleanup

Testing

  • Verified zero references to any of the five column names (snake_case or camelCase) anywhere outside packages/db/migrations
  • Confirmed all five columns are empty across every row in production, and that nothing depends on them — no index, constraint, view, rule, trigger, function, publication, or generated column
  • Diffed every table's column count against the Drizzle snapshot: user_table_definitions is the only table with model/database drift
  • Idempotency tested against a scratch Postgres — ran the migration three times, clean each run, row data intact. Single ALTER with DROP COLUMN IF EXISTS clauses, so one lock acquisition and a no-op replay after a lock_timeout retry
  • bun run check:migrations origin/staging ✓, bun run lint ✓, bun run check:audits (37 audits) ✓

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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.
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 28, 2026 1:23am

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR completes the table-jobs cutover by dropping five obsolete import-state columns that have already been removed from the application schema and moved to table_jobs.

  • Adds one replay-safe contract migration using a single guarded ALTER TABLE.
  • Adds migration 0310 to the ordered journal.
  • Carries forward the Drizzle snapshot, where the obsolete columns were already absent.

Confidence Score: 5/5

The PR appears safe to merge because the removed columns have no remaining repository consumers and the migration is guarded, replay-safe, and fail-closed for unexpected dependencies.

Migration 0233 moved import state into table_jobs, current application and registered script-migration code no longer use the old columns, and the new metadata preserves the ordered migration chain without introducing a schema mismatch.

Important Files Changed

Filename Overview
packages/db/migrations/0310_drop_orphaned_table_import_columns.sql Safely removes five obsolete physical columns after the earlier expand-and-contract cutover, using guarded drops without CASCADE.
packages/db/migrations/meta/0310_snapshot.json Carries forward the current Drizzle schema metadata; the removed columns were already absent from prior snapshots.
packages/db/migrations/meta/_journal.json Correctly appends migration 0310 after migration 0309.

Reviews (1): Last reviewed commit: "chore(db): drop orphaned import_* column..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit fa00b63 into staging Aug 28, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the investigate/table-col-count branch August 28, 2026 01:24
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