Skip to content

PgExclusion ImpactOf compares a target-named table with source-named key columns #172

Done

Description

@CaffeinatedCoder

Found by the pre-tag review of 948496a..0ee827d (the review for v11.0.0-preview.1).

PgExclusionContributor.ImpactOf answers a dropped column with descriptor.GoesWith(new Dependency.Column(dropped.Table, dropped.Column)) (src/CodoMetis.EFCore.SchemaKit.PostgreSQL/Internal/PgExclusionContributor.cs:178). The change names the table as the target has it, and KeyColumns names it as the source has it. CLAUDE.md forbids exactly this pattern for the SQL Server contributor of the second provider: find a changed column by its name.

Scenario: a migration renames role_grants and also drops and adds an element column, for example by making GranteeId a stored computed column, which Npgsql writes as drop and add (#80). GoesWith finds no match, so the answer is RebuildAround instead of Lost. Without the rename the answer is Lost, and there is no drop.

  • Contexts.Diff<Models.Scheduling, Models.SchedulingWithAComputedGrantee>(): no DROP CONSTRAINT.
  • The same diff with the table renamed to grants_renamed: ALTER TABLE role_grants DROP CONSTRAINT ex_role_grant_active_period; first.

Today that is harmless. A drop before EF Core's operations and a create after them is right whether or not the server would have taken the constraint with the column. It becomes a defect wherever RebuildAround is not the safer answer.

Fix: compare by the column's name, or carry the table forward through the renames before comparing. Add a test with a table rename beside each column change of the impact table.

Does it block preview.1?

No. It answers with the more conservative choice, and the migration applies with the constraint in place.

Activity

  1. added this to the 11.0.0 milestone on Nov 17, 2026
  2. added
    bug
    severity/low
    package/postgresql
    area/constraints
    on Nov 17, 2026
  3. CaffeinatedCoder commented on Nov 25, 2026

    @CaffeinatedCoder
    OwnerAuthor

    2026-11-25: fixed by #117 (PR #197), and held now. The package's impact table finds the changed column by its name, not with the change's table. On the branch fix/172-171-tidy: An_element_column_that_becomes_computed_beside_a_rename_of_its_table_is_found_by_its_name has no DROP CONSTRAINT in the diff with the table renamed, and fails when the column is looked up with the table; Making_an_element_column_a_computed_one_and_renaming_its_table applies it on PostgreSQL 16 and 18 and finds the constraint on the table under its new name.

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/constraintsbugpackage/postgresqlseverity/low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions