Skip to content

An operation scaffolded by an early 5.x with CustomTemporal:WithoutOverlaps replays as a plain unique constraint #110

Closed

Description

@CaffeinatedCoder

Found in the plan debate after the pre-preview sweep of main @ 948496a (GPT's point, from 5.x's generator); reproduced in a scratch test.

What happens

Before 5.x wrote temporal DDL as SQL at design time, it scaffolded AddUniqueConstraint(…) with the annotation CustomTemporal:WithoutOverlaps, and its generator rendered the constraint from it (NpgsqlComplexIndexSqlGenerator.Generate(AddUniqueConstraintOperation), kept there "for backward compatibility"). SchemaKit has no rewriter for it, so the operation goes to Npgsql's generator as it is:

var op = new AddUniqueConstraintOperation { Table = "Tariff", Name = "AK_Tariff_ProductId_Valid", Columns = ["ProductId", "Valid"] };
op.AddAnnotation("CustomTemporal:WithoutOverlaps", "Valid");
context.GetService<IMigrationsSqlGenerator>().Generate([op], null);
ALTER TABLE "Tariff" ADD CONSTRAINT "AK_Tariff_ProductId_Valid" UNIQUE ("ProductId", "Valid");

A plain unique constraint under the temporal one's name. A fresh database built from such a history accepts overlapping periods, and nothing says so. The same shape, read and not run: a CreateIndexOperation marked CustomIndex:AfterTableRebuild (SQLite) and the temporal foreign key's CustomTemporal:ForeignKey* annotations.

Who meets it

A project whose migration history has such an operation and whose current snapshot holds nothing #93 refuses, so that Migrate() gets as far as replaying it. That is narrow: a snapshot that still holds a temporal constraint is stopped before. It is the generator's side of what #93 closed for the snapshot, and it fails the other way: open.

Change

Until the rewriters of legacy replay exist (#28), SchemaKitSqlGenerator refuses an operation that carries an annotation of 5.x which only 5.x's generator rendered, naming the migration's operation and #28. A rewriter leaves the guard by handling the annotation, as a reader leaves #93's.

The list is 5.x's own, checked against its two generators and the differs that stamped for them over every tag (1.0.0 to v5.6.0): CustomTemporal:WithoutOverlaps on an AddUniqueConstraintOperation (to 5.0.1), CustomTemporal:ForeignKeyDependentPeriod and CustomTemporal:ForeignKeyPrincipalPeriod on an AddForeignKeyOperation (5.0.1), and on a CreateIndexOperation CustomIndex:IndexParts (every version, expression indexes and null ordering; not in the first guess) and CustomIndex:AfterTableRebuild (from 5.5.0, SQLite). 5.x had no generator for SQL Server.

Test

The operation above refused, in the kernel's tests on all three providers; shown to fail without the check. With #28: the same operation rendered as 5.x rendered it, compared by catalog.

Activity

  1. added this to the 11.0.0 milestone on Nov 14, 2026
  2. added
    bug
    silent
    package/core
    package/postgresql
    severity/medium
    area/migrations
    on Nov 14, 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/migrationsbugpackage/corepackage/postgresqlseverity/mediumsilent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions