From 9c3b34a832b6f9fee7ade49f259a2377ff322e64 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Sun, 19 Jul 2026 12:32:37 -0300 Subject: [PATCH] fix(db): renumber usage-identity migration to 127 (collides with 123_quota_auto_ping) Base-red found during pre-merge validation: the fork's migration was authored as 123_usage_history_account_identity.sql, but release/v3.8.49 already carries 123_quota_auto_ping.sql at that same numeric prefix. getMigrationFiles() throws "Migration version collision detected" for any duplicate version, which was failing every test that boots the DB (db-migration-runner, usage-migrations, usage-analytics-route). Renamed to 127 (next free slot after 126_reasoning_routing_rules.sql) and updated the matching test-file-path references. Co-authored-by: Xiangzhe --- ...dentity.sql => 127_usage_history_account_identity.sql} | 2 +- tests/unit/db-migration-runner.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/lib/db/migrations/{123_usage_history_account_identity.sql => 127_usage_history_account_identity.sql} (98%) diff --git a/src/lib/db/migrations/123_usage_history_account_identity.sql b/src/lib/db/migrations/127_usage_history_account_identity.sql similarity index 98% rename from src/lib/db/migrations/123_usage_history_account_identity.sql rename to src/lib/db/migrations/127_usage_history_account_identity.sql index fbc8ad0af0..c456c9260d 100644 --- a/src/lib/db/migrations/123_usage_history_account_identity.sql +++ b/src/lib/db/migrations/127_usage_history_account_identity.sql @@ -1,4 +1,4 @@ --- Migration 123: Snapshot stable account identity on usage events. +-- Migration 127: Snapshot stable account identity on usage events. -- Startup schema ensure adds the columns first so an interrupted pre-marker -- upgrade can rerun this atomic backfill and index creation. diff --git a/tests/unit/db-migration-runner.test.ts b/tests/unit/db-migration-runner.test.ts index 85a75ae8cb..3d96b79069 100644 --- a/tests/unit/db-migration-runner.test.ts +++ b/tests/unit/db-migration-runner.test.ts @@ -65,7 +65,7 @@ test("migration 123 backfills account snapshots and creates its index", async () const runner = await importFresh("src/lib/db/migrationRunner.ts"); const db = createDb(); const migrationSql = fs.readFileSync( - "src/lib/db/migrations/123_usage_history_account_identity.sql", + "src/lib/db/migrations/127_usage_history_account_identity.sql", "utf8" ); @@ -97,7 +97,7 @@ test("migration 123 backfills account snapshots and creates its index", async () `); const count = withMockedMigrationFs( - { "123_usage_history_account_identity.sql": migrationSql }, + { "127_usage_history_account_identity.sql": migrationSql }, () => runner.runMigrations(db) ); const rows = db @@ -130,7 +130,7 @@ test("migration 123 preserves exact dedup identity and ignores non-string JSON s const runner = await importFresh("src/lib/db/migrationRunner.ts"); const db = createDb(); const sql = fs.readFileSync( - "src/lib/db/migrations/123_usage_history_account_identity.sql", + "src/lib/db/migrations/127_usage_history_account_identity.sql", "utf8" ); @@ -172,7 +172,7 @@ test("migration 123 preserves exact dedup identity and ignores non-string JSON s ('', ''); `); - const count = withMockedMigrationFs({ "123_usage_history_account_identity.sql": sql }, () => + const count = withMockedMigrationFs({ "127_usage_history_account_identity.sql": sql }, () => runner.runMigrations(db) ); const rows = db