Skip to content

Index and constraint names are not checked against implicit identity/serial sequences #115

Closed

Description

@CaffeinatedCoder

Problem

#82 (PR #106) adds the model's tables, views and sequences to the PostgreSQL relation-namespace check. The sequence PostgreSQL creates implicitly for an identity or serial column is not in the model, so it is still missed:

b.ToTable("rows");                                   // "Id" integer GENERATED BY DEFAULT AS IDENTITY (Npgsql's default)
b.HasComplexIndex(x => x.Code, indexName: "rows_Id_seq");

This scaffolds cleanly and fails at apply. Checked on PostgreSQL 18: ERROR: relation "rows_Id_seq" already exists (42P07).

Reaching it takes a deliberately odd name. It is filed because #82's check now looks complete when it is not.

Fix

Add {table}_{column}_seq for every column Npgsql maps as identity or serial (Npgsql:ValueGenerationStrategy IdentityByDefault/IdentityAlways/SerialColumn, or a serial store type) to the relation namespace in ValidateNamesAcrossKinds. PostgreSQL truncates and de-duplicates that name when it is long or taken, so compare only names under 63 bytes, and say so. Loud.

Found while building #82.

Activity

  1. added this to the 5.5.0 milestone on Oct 20, 2026
  2. added
    bug
    severity/low
    package/postgresql
    area/indexes
    area/constraints
    on Oct 20, 2026
  3. added 2 commits that reference this issue on Oct 20, 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/constraintsarea/indexesbugpackage/postgresqlseverity/low

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions