Repository navigation
feat!: the dialect says what a migration operation does - #199
Merged
Merged
Conversation
ISchemaDialect.EffectOf answers an operation with an OperationEffect: the
BaseChanges it stands for, that the provider writes nothing for it, or
that nobody knows it. The planner asks it of every operation. The
kernel's SchemaDialect answers EF Core Relational's operations, and SQL
Server's and SQLite's until each has a dialect of its own.
NpgsqlSchemaDialect says Npgsql's rules, each held against its generator:
a change of a generated tsvector is a dropped column, its database
operations touch nothing, and a table moved back to the default schema
is not written.
An operation that is not written is refused when a declared object is on
one of its tables: the table would stay where it was, and the object
with it or a statement after it would fail. For Npgsql the way out is to
name the schema, ToTable("x", "public"), which it writes.
Closes #198
Closes #105
Co-Authored-By: Claude Fable 5.2 <[email protected]>
CaffeinatedCoder
enabled auto-merge
November 25, 2026 16:24
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #198
Closes #105
The slice of #116 for
preview.2(decided 2026-11-25).Problem
What a
MigrationOperationdoes to the database is the provider's rule, and the kernel held copies of three providers' rules. A provider's package had no way to say what its generator does otherwise. One case had nowhere to be said at all:ToTable("role_grants", "grants")becomesToTable("role_grants"), Npgsql 11.0.0 writes no statement for that move, and the planner took the table for moved. A constraint on it stayed ingrantswith the table, or a statement written after the move failed with 42P01 (#105).Change
ISchemaDialect.EffectOf(MigrationOperation)answers with anOperationEffect, a closed union:Changes(theBaseChanges the operation stands for; none for one that touches nothing an object depends on),NotWritten(the tables it is about and the way out, as a sentence of the provider's package),Unknown. The planner asks it of every operation, in their order.SchemaDialectanswers EF Core Relational's operations, and SQL Server's and SQLite's as before.NpgsqlSchemaDialectsays Npgsql's own: a change of a generatedtsvectoris a dropped column, its database operations touch nothing, and a table moved back to the default schema is not written. Each is held against Npgsql's generator inNpgsqlOperationEffectTests.ToTable("x", "public");Moving_the_table_back_with_the_default_schema_namedapplies that on PostgreSQL 16 and 18 and finds the table and its constraint whereEnsureCreated()puts them. Taking the name off again afterwards is no move.Deviations from the proposal on #116:
The_dialect_says_what_an_operation_doesandAn_operation_of_another_package_is_taken_when_the_dialect_describes_ithold the seam in the kernel's tests with a dialect of their own.NotWrittencarries the way out. Only the provider's package knows it, and a refusal without it names no fix.Tests
Offline: 772 (kernel), 209 (PostgreSQL package), 90 (second provider); the API probes: 127. Live: 4 and 77 on PostgreSQL 16 and on 18, 86 on SQL Server 2022. The consumer smoke test: 47 rows.
Nine rules were changed in turn, each run with the live tests on PostgreSQL 18, and a test failed for each:
The_dialect_says_what_an_operation_does, the refusal'sThe_dialect_says_what_an_operation_doestsvectoris an alterationThe_dialect_says_a_dropped_column_where_the_generator_drops_one(the first form of this change was no change, and was redone)Every_operation_type_of_Npgsql_is_describedbreaking:ISchemaDialecthas a new member, in the contract (SK9001), and a migration that applied and left the table behind is refused.🤖 Generated with Claude Code