Skip to content

EF Core sweep follow-ups: sequences, check constraints, computed columns, index methods, drift detection, Oracle/MySql parity - #372

Merged
jeremydmiller merged 1 commit into
masterfrom
feat/efcore-sweep-followups
Jul 18, 2026
Merged

EF Core sweep follow-ups: sequences, check constraints, computed columns, index methods, drift detection, Oracle/MySql parity#372
jeremydmiller merged 1 commit into
masterfrom
feat/efcore-sweep-followups

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Follow-up round to #361, working through the remaining gaps the schema-parity sweep documented.

What's here

  • SequencesSequenceBase.IncrementBy (HiLo's block size is load-bearing), a Migrator.CreateSequence seam (PG / SQL Server / Oracle; MySQL & SQLite return null), and GetSchemaObjectsForMigration mapping model sequences (UseHiLo, UseSequence, HasSequence) ahead of the tables. CreateMigrationAsync now includes them. SQL Server's UseSequence NEXT VALUE FOR defaults flow through and match.
  • Check constraintsTableCheckConstraint + ITable.AddCheckConstraint, CREATE TABLE emission, catalog reads, and delta comparison on PostgreSQL and SQL Server. Deliberately conservative: only constraints the model declares are compared, and constraints Weasel doesn't know about (inline column checks, third-party) are never dropped.
  • Computed columnsITableColumn.ComputedExpression/ComputedColumnIsStored, emitted on PG (GENERATED ALWAYS AS ... STORED), SQL Server (AS (...) [PERSISTED]), MySQL, and SQLite (mapped onto its existing generated-column model). Oracle throws rather than silently emitting a plain column.
  • Index methodsITableIndex.Method; Npgsql HasMethod("gin") now maps automatically (no more escape hatch for gin).
  • Opt-in column drift detectionITable.DetectColumnDrift: default-expression + nullability comparison for otherwise-matching columns with ALTER COLUMN corrections on PG and SQL Server (incl. dropping SQL Server's server-named default constraints). Off by default — datetime literal canonicalization isn't stable enough to make it safe blanket-on, and a false positive means perpetual re-apply. Direct provider tests cover changed/dropped defaults and nullability drift round-trips.
  • Oracle casing parity — the same quoted-identifier treatment PostgreSQL got in EF Core mapping sweep: schema parity with EF Core migrations (tables + indexes) #361, honored by PreserveIdentifierCase (folded convention byte-identical), covered by DB-free DDL tests (live verification rides on ci-build-oracle; the arm64 local container won't boot).
  • MySQL in EF CI — service added to ci-build-efcore.yml, MySql filter removed (net9.0), EnsureDeleted hazard removed from its e2e tests. Verified locally against mysql:8.0.
  • Also: SQL Server FetchExisting now reads column defaults/nullability, SS ItemDelta matching is case-insensitive, and the EF docs (docs/efcore/table-mapping.md) are updated for casing/sequences/owned types/drift.

Verification

  • EF suite: 64/64 (net9.0) + 62/62 (net10.0) — including 5 new comparison suites (PG sequences, PG checks+computed, SS sequences, SS checks+computed)
  • Weasel.Postgresql.Tests 767 ✅ (5 new drift tests), Weasel.SqlServer.Tests 302 ✅ (3 new drift tests), Weasel.Sqlite.Tests 361 ✅, Weasel.Core.Tests 21 ✅, Oracle DDL unit tests 4/4 ✅ (one pre-existing env-only failure needing live Oracle, unchanged on clean master)

🤖 Generated with Claude Code

…d columns, index methods, drift detection, Oracle/MySql parity

Follow-ups to the EF Core schema-parity sweep (#361):

- Sequences: SequenceBase.IncrementBy (HiLo block size), Migrator.CreateSequence
  seam (PG/SS/Oracle), GetSchemaObjectsForMigration maps model sequences
  (UseHiLo/UseSequence/HasSequence) ahead of tables; CreateMigrationAsync uses it
- Check constraints: TableCheckConstraint in Weasel.Core, ITable.AddCheckConstraint,
  CREATE emission + catalog reads + conservative delta comparison on PG and SS
  (only declared checks compared; unknown constraints never dropped)
- Computed columns: ITableColumn.ComputedExpression/ComputedColumnIsStored with
  emission on PG (STORED), SS (AS ... PERSISTED), MySQL, SQLite (mapped onto its
  existing generated-column model); Oracle throws rather than emitting wrong DDL
- Index methods: ITableIndex.Method maps Npgsql HasMethod("gin") automatically
- Opt-in column drift detection: ITable.DetectColumnDrift compares canonicalized
  defaults + nullability of matching columns and emits ALTER corrections on PG/SS;
  off by default (datetime literal canonicalization is not stable enough to be safe)
- Oracle casing parity: preserve-case columns/PK/FK are quoted (folded convention
  unchanged), covered by DB-free DDL tests
- MySQL: EF CI service added, EnsureDeleted hazard removed from its e2e tests
- SQL Server FetchExisting reads column defaults/nullability; ItemDelta matching
  case-insensitive; EF docs updated (casing, sequences, drift, owned types)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit ecc1f25 into master Jul 18, 2026
23 checks passed
@jeremydmiller
jeremydmiller deleted the feat/efcore-sweep-followups branch July 18, 2026 20:13
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