Skip to content

Commit 822ac9a

Browse files
dmealingclaude
andcommitted
refactor(csharp): pre-merge gate on migrate engine
code-reviewer verdict: clean port, no correctness findings. Applied: - code-simplifier: BlockedReason nested ternaries → guarded `when` arms (status classification + messages byte-identical; reads closer to the TS reference). - review MINOR: document that ignoreTables defaults to empty by design (a live-DB caller passes the migration-history table, e.g. __EFMigrationsHistory). Full solution green (308). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 26ca3d5 commit 822ac9a

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

server/csharp/MetaObjects.Codegen/Migrate/SchemaDiff.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public static class SchemaDiff
2020
/// <summary>
2121
/// Produces the changes to bring <paramref name="actual"/> to <paramref name="expected"/>.
2222
/// Tables whose name matches an <paramref name="ignoreTables"/> pattern (exact or
23-
/// <c>*</c>-glob) are excluded from both sides.
23+
/// <c>*</c>-glob) are excluded from both sides. The default is empty by design; a
24+
/// live-DB caller should pass the migration-history table (e.g. <c>"__EFMigrationsHistory"</c>)
25+
/// so it isn't surfaced as a drop.
2426
/// </summary>
2527
public static DiffResult Diff(
2628
SchemaSnapshot expected,
@@ -177,14 +179,13 @@ private static void ApplyStatus(IReadOnlyList<Change> changes, AllowOptions allo
177179
Change.DropIndex => allow.DropIndex ? null : "destructive: drop-index not allowed (pass allow.dropIndex)",
178180
Change.DropFk => allow.DropFk ? null : "destructive: drop-fk not allowed (pass allow.dropFk)",
179181

180-
Change.ChangeColumnType t => SqlType.IsWidening(t.From, t.To)
181-
? null
182-
: allow.TypeChange ? null : "lossy type change (pass allow.typeChange)",
182+
// Widening type changes are always allowed.
183+
Change.ChangeColumnType t when SqlType.IsWidening(t.From, t.To) || allow.TypeChange => null,
184+
Change.ChangeColumnType => "lossy type change (pass allow.typeChange)",
183185

184186
// from = actual.nullable, to = expected.nullable; notnull→nullable is safe.
185-
Change.ChangeColumnNullable n => (n.From == false && n.To)
186-
? null
187-
: allow.NullableToNotNull ? null : "nullable→notnull requires existing data to satisfy (pass allow.nullableToNotNull)",
187+
Change.ChangeColumnNullable n when (!n.From && n.To) || allow.NullableToNotNull => null,
188+
Change.ChangeColumnNullable => "nullable→notnull requires existing data to satisfy (pass allow.nullableToNotNull)",
188189

189190
_ => null,
190191
};

0 commit comments

Comments
 (0)