Skip to content

Effect adapters, the seam: the dialect says what a migration operation does, Npgsql's rules move to its package, and a move that is not written is refused #198

Done

Description

@CaffeinatedCoder

2026-11-25: in PR #199 (feat/198-effects-seam). Offline: 772 of the kernel's tests, 209 of the PostgreSQL package's, 90 of the second provider's; the API probes' 127. Live: 4 and 77 on PostgreSQL 16 and on 18, 86 on SQL Server 2022, the consumer smoke test's 47 rows.

What is there:

  • ISchemaDialect.EffectOf(MigrationOperation) answers with an OperationEffect, a closed union: Changes (the BaseChanges 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.
  • The kernel's SchemaDialect answers EF Core Relational's operations, and SQL Server's and SQLite's as before.
  • NpgsqlSchemaDialect says Npgsql's own: 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. Each is held against Npgsql's generator in NpgsqlOperationEffectTests.
  • The planner refuses an operation that is not written when a declared object, on either side, is on one of its tables (A table moved back to the default schema stays where it was on Npgsql, and a statement written after the move fails with 42P01 #105). The way out for Npgsql is to name the schema, ToTable("x", "public"); Moving_the_table_back_with_the_default_schema_named applies that on PostgreSQL 16 and 18 and finds the table and its constraint where EnsureCreated() puts them. Taking the name off again afterwards is no move.
  • A context that declares nothing on the table is not touched.

Deviations from the proposal on #116:

  • The second provider's probe dialects do not override the seam. They have no rule to say that the kernel's dialect lacks, so an override would change nothing a test could see. The_dialect_says_what_an_operation_does and An_operation_of_another_package_is_taken_when_the_dialect_describes_it hold the seam in the kernel's tests with a dialect of their own.
  • NotWritten carries the way out. Only the provider's package knows it, and a refusal without it names no fix.
  • No service by which a third package describes its operation types. A dialect can describe them, as the test shows; a second way in waits for a package that needs it.

Nine rules were changed in turn, each run with the live tests on PostgreSQL 18, and a test failed for each:

Changed Fails
The planner asks the kernel's table, not the dialect both of the kernel's seam tests, the refusal's
An operation that is not written is passed over The_dialect_says_what_an_operation_does, the refusal's
It is refused whatever is on its table The_dialect_says_what_an_operation_does
An unknown operation is taken for harmless two of the kernel's
A move the dialect names does not carry names forward three of the PostgreSQL package's
Npgsql: a changed tsvector is an alteration two rows of The_dialect_says_a_dropped_column_where_the_generator_drops_one (the first form of this change was no change, and was redone)
Npgsql: the move back is a move two
Npgsql: leaving the default schema's name is not written either three, the live test among them
Npgsql: its database operations are unknown Every_operation_type_of_Npgsql_is_described

Part of #116 (decided 2026-11-25): the slice for preview.2. Takes #105's refusal with it.

Problem

What a MigrationOperation does to the database is the provider's rule, and the kernel holds copies of three providers' rules. A provider's package has no way to say what its generator does otherwise, and Npgsql's move back to the default schema, for which its generator writes no statement (measured on 11.0.0), has nowhere to be said: the planner takes the table for moved (#105).

Change

  • ISchemaDialect gets one member that turns a MigrationOperation into the BaseChanges it stands for, or says it does not know the operation. The kernel's SchemaDialect answers as the kernel does today. A provider's dialect overrides it.
  • Npgsql's rules move to NpgsqlSchemaDialect: its own operation types, the tsvector part of the drop-and-add rule, and the move back to the default schema, which it says is not written.
  • A move that is not written is refused when a model declares an object on that table, with the table named and the way to write the move by hand.
  • The second provider's probe dialects override the member for a rule each.

Not here: SQLite's and SQL Server's rules stay in the kernel until each has a dialect to move to (#29, the first SQLite object), and with them the convention test that no provider is named under the kernel's src. A service by which a third package describes its own operation types is not built until there is one to describe.

Done when

The PostgreSQL package's tests hold each of Npgsql's rules against its generator, a live test shows the table moved back by hand ends where EnsureCreated() puts it, and the refusal's test fails without the rule.

Activity

  1. added this to the 11.0.0 milestone on Nov 25, 2026
  2. added
    enhancement
    breaking
    package/core
    package/postgresql
    area/migrations
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationsbreakingenhancementpackage/corepackage/postgresql

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions