Skip to content

Delete guard: design for 5.x with a no-migration transfer to SchemaKit (ROADMAP D1) #64

Closed as not planned

Description

@CaffeinatedCoder

2026-11-11: the guard is tracked in SchemaKit now, as CaffeinatedCoder/CodoMetis.EFCore.SchemaKit#47 in its 11.0.0 milestone. It ships there first (ROADMAP D1); 5.x takes fixes only, so the 5.x half of this design, the 5.6.0 placement and the transfer are not built. The findings below were carried into that issue. The design document stays readable on the branch of #65.

Goal

Design the delete guard (ROADMAP.md D1, section 4.2) so that it can ship on EFCore.ComplexIndexes 5.x, if an EF Core 10 application needs it, and move to CodoMetis.EFCore.SchemaKit (#37, CaffeinatedCoder/CodoMetis.EFCore.SchemaKit#11) without a migration (#59), extensible there to update guards, append-only tables, immutable columns and guards on SQL Server and SQLite.

The consumer case: an application had to hand-write CREATE TRIGGER in a migration to stop rows in a final state from being deleted. Nothing in the model records it, nothing diffs it, and EnsureCreated() never creates it.

Deliverable

design/delete-guard.md in a draft PR. No implementation.

Findings so far (verified on PostgreSQL 14 and 18)

ROADMAP 4.2 needs these corrections before it is built:

  • ALTER TRIGGER … RENAME keeps the trigger's arguments, so a name passed as TG_ARGV[0] goes stale and the application's error mapping stops matching. Use TG_NAME.
  • CREATE OR REPLACE FUNCTION fails with 42501 under a second migration role, and would let a later package version change every existing guard. Create if missing; freeze the body.
  • ALTER COLUMN … TYPE on a column in a trigger's WHEN fails at apply time. Guards reading an altered column need a forced rebuild.
  • The typed-filter translation lets a row with a null column through a guard whose C# predicate covers it (Status != "Draft"). Guards need C# null semantics.
  • Trigger names over 63 bytes are truncated with only a NOTICE; a guard may share its name with a CHECK constraint.

Recommendation (in the doc)

Build it in a 5.6.0, not in 5.5.0; 4.1 is not a prerequisite on 5.x. The 5.x "fixes only" rule needs one narrow exception, worded in section 10. A 5.6.0 epic is proposed, not created: milestone left empty until the maintainer decides.

Activity

  1. added
    enhancement
    package/postgresql
    area/constraints
    area/migrations
    on Oct 19, 2026
  2. CaffeinatedCoder commented on Nov 11, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Not built on 5.x. Tracked in SchemaKit as CaffeinatedCoder/CodoMetis.EFCore.SchemaKit#47.

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/constraintsarea/migrationsenhancementpackage/postgresql

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions