From 660343ede2821d83b8f16d867c13f7b5a77630cf Mon Sep 17 00:00:00 2001 From: Alex McAuliffe Date: Mon, 15 Jun 2026 15:21:30 +0100 Subject: [PATCH 1/2] Add test showing that migration provides delta --- ...614_revision_column_int_for_IRevisioned.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs b/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs index 9c1756488c..a534e901be 100644 --- a/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs +++ b/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs @@ -133,6 +133,28 @@ await conn.CreateCommand( (await readVersionColumnType(typeof(RevisionedDoc))).ShouldBe("bigint"); } + [Fact] + public async Task existing_9x_bigint_column_for_IRevisioned_is_tolerated_not_narrowed_migration_check() + { + // The reverse-direction safety: a deployment that already migrated to V9-with-bigint + // (before this fix) MUST NOT get force-narrowed to integer on the next apply — a + // `USING mt_version::integer` cast would silently truncate any out-of-range value. + // The diff treats bigint-actual + integer-desired as compatible (no SQL emitted). + StoreOptions(opts => opts.Schema.For()); + await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); + + await using (var conn = new NpgsqlConnection(ConnectionSource.ConnectionString)) + { + await conn.OpenAsync(); + await conn.CreateCommand( + $"alter table {SchemaName}.mt_doc_revisioneddoc alter column mt_version type bigint") + .ExecuteNonQueryAsync(); + } + + var migration = await theStore.Storage.CreateMigrationAsync(); + migration.Difference.ShouldBe(SchemaPatchDifference.None); + } + // ---- CRUD round-trip on both shapes ---- [Fact] From 9fa1369edb64069da8cff3c5fadb887048765712 Mon Sep 17 00:00:00 2001 From: Alex McAuliffe Date: Mon, 15 Jun 2026 15:25:51 +0100 Subject: [PATCH 2/2] Add test showing that assert check throws --- .../Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs b/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs index a534e901be..93bdf231e0 100644 --- a/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs +++ b/src/CoreTests/Bugs/Bug_4614_revision_column_int_for_IRevisioned.cs @@ -134,7 +134,7 @@ await conn.CreateCommand( } [Fact] - public async Task existing_9x_bigint_column_for_IRevisioned_is_tolerated_not_narrowed_migration_check() + public async Task existing_9x_bigint_column_for_IRevisioned_is_tolerated_not_narrowed_assert_check() { // The reverse-direction safety: a deployment that already migrated to V9-with-bigint // (before this fix) MUST NOT get force-narrowed to integer on the next apply — a @@ -151,8 +151,7 @@ await conn.CreateCommand( .ExecuteNonQueryAsync(); } - var migration = await theStore.Storage.CreateMigrationAsync(); - migration.Difference.ShouldBe(SchemaPatchDifference.None); + await theStore.Storage.Database.AssertDatabaseMatchesConfigurationAsync().ShouldNotThrowAsync(); } // ---- CRUD round-trip on both shapes ----