Skip to content

fix(migrations): renumber the AI-support migration above the release line - #323

Merged
camreeves merged 1 commit into
masterfrom
fix/ai-support-migration-ordering
Aug 6, 2026
Merged

fix(migrations): renumber the AI-support migration above the release line#323
camreeves merged 1 commit into
masterfrom
fix/ai-support-migration-ordering

Conversation

@camreeves

Copy link
Copy Markdown
Contributor

The problem

202607050000000_add_ai_support_agent_tables.sql is 15 digits where every recent migration is 17. Its version_id is therefore ~100× smaller than migrations already applied in the field:

already applied on any 2.2607.3 database :  20,260,730,100,500,000
the AI-support migration                 :     202,607,050,000,000

micrate sorts by version_id, so this migration lands before ones that are already applied, and verify_unordered_migrations raises Micrate::UnorderedMigrationsException. At that point nothing further applies — including 20260730101000000_alter_user_logged_out_at_timestamptz.sql.

This is already happening

The dev server's init is crash-looping on exactly this right now:

Unhandled exception:  (Micrate::UnorderedMigrationsException)
  from lib/micrate/src/micrate.cr:139:7 in 'verify_unordered_migrations'
  from lib/micrate/src/micrate.cr:178:5 in 'migration_plan'
  ...
  from src/migrations.cr:12:7 in 'apply_all'

I compared every migration on disk against dev's applied set. This file is the only one out of order.

It would also have broken the next platform release: any client database at 2.2607.3 has 20260730100500000 applied, so this migration would refuse on upgrade and take the rest of the chain with it.

The fix

Renumbered to 20260806100500000 — above everything currently released.

Padding to 17 digits alone would not be sufficient: 20260705000000000 still predates the 2026-07-30 migrations already in the field.

Why renaming is safe here

  • Not applied anywhere — no micrate_db_version row for it on dev
  • Fully idempotent — every statement is CREATE TABLE/INDEX IF NOT EXISTS (12 tables, 52 indexes), so even a re-application on a database that somehow had it would be a no-op
  • No references — nothing in the codebase mentions the filename

Content is untouched. This is a pure rename.

…line

`202607050000000_add_ai_support_agent_tables.sql` is 15 digits where every
recent migration is 17, so its version_id is ~100x smaller than the
migrations already applied everywhere:

  already applied on any 2.2607.3 database :  20,260,730,100,500,000
  the AI-support migration                 :     202,607,050,000,000

micrate sorts by version_id, so this lands BEFORE migrations that are
already applied and `verify_unordered_migrations` raises
`Micrate::UnorderedMigrationsException` — at which point NOTHING further
applies, including 20260730101000000_alter_user_logged_out_at_timestamptz.

This is not hypothetical. It is already breaking the dev server: `init`
is crash-looping on exactly this exception right now, and a scan of every
migration against dev's applied set shows this file is the ONLY one out
of order.

Padding to 17 digits would not be enough — 2026-07-05 still predates the
2026-07-30 migrations already in the field — so it is renumbered to
20260806100500000, above everything currently released.

Renaming is safe here: the migration has not been applied anywhere (no
`micrate_db_version` row for it on dev), and every statement in it is
`CREATE TABLE/INDEX IF NOT EXISTS` (12 tables, 52 indexes), so even a
re-application would be a no-op. Nothing in the codebase references the
filename.

Content is untouched — this is a pure rename.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the type: bug something isn't working label Aug 6, 2026

@naqvis naqvis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@camreeves
camreeves merged commit 9ff188d into master Aug 6, 2026
7 of 9 checks passed
@camreeves
camreeves deleted the fix/ai-support-migration-ordering branch August 6, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants