Skip to content

Preserve tick count constraints in SQLite migrations - #1540

Open
salasebas wants to merge 1 commit into
Shopify:mainfrom
salasebas:agent/fix-sqlite-migration-defaults
Open

Preserve tick count constraints in SQLite migrations#1540
salasebas wants to merge 1 commit into
Shopify:mainfrom
salasebas:agent/fix-sqlite-migration-defaults

Conversation

@salasebas

Copy link
Copy Markdown
Contributor

Running the full migration history on a Rails 8.1 SQLite database drops
DEFAULT 0 and NOT NULL from maintenance_tasks_runs.tick_count when
the 2022 migration changes it to bigint. Runs can then persist
tick_count = NULL and render indeterminate progress after succeeding.

Preserve the constraints explicitly in the historical migration for new
installations. Add a corrective migration for affected databases that
normalizes existing NULL values to zero and restores bigint,
DEFAULT 0, and NOT NULL. Databases with the expected schema are
skipped to avoid an unnecessary SQLite table rebuild.

The corrective migration is intentionally irreversible because the
NULL-to-zero normalization cannot be undone reliably.

Testing

  • Rails 7.2, 8.0, and 8.1 with SQLite
  • Fresh installation migration history
  • Legacy affected database migration

@salasebas
salasebas marked this pull request as ready for review August 19, 2026 08:00
SQLite drops unstated column options on t.change. Restate default and
null on tick_count when converting to bigint, and add a corrective
migration for databases that already lost those constraints.
@salasebas
salasebas force-pushed the agent/fix-sqlite-migration-defaults branch from 5bdb3f3 to 9a1eb3d Compare August 25, 2026 16:26
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