Problem statement
MigrationNamingMixin currently validates only indexes and foreign keys. PostgreSQL also creates named constraints that follow naming conventions but are not checked:
- CHECK constraints — e.g.
chk_orders_amount_positive
- UNIQUE constraints — exist as standalone constraints (separate from unique indexes)
- PRIMARY KEY constraints — e.g.
pk_users (distinct from the _pkey index name)
- EXCLUDE constraints — less common, but present in some schemas
Without validation, these can silently drift from the team's naming convention.
Proposed solution
Extend fetch_table_naming_results and validate_naming_results to collect and validate named constraints via Inspector.get_check_constraints(), Inspector.get_unique_constraints(), and Inspector.get_pk_constraint().
Add corresponding class variables to MigrationNamingMixin (and expose on MigrationTestBase):
allowed_check_prefixes: ClassVar[list[str]] = ["chk_"]
allowed_check_suffixes: ClassVar[list[str]] = []
allowed_uq_prefixes: ClassVar[list[str]] = ["uq_"]
allowed_uq_suffixes: ClassVar[list[str]] = []
allowed_pk_prefixes: ClassVar[list[str]] = ["pk_"]
allowed_pk_suffixes: ClassVar[list[str]] = ["_pkey"]
Scope
New feature — additive, fully backward-compatible (empty or sensible defaults for all new attributes).
Problem statement
MigrationNamingMixincurrently validates only indexes and foreign keys. PostgreSQL also creates named constraints that follow naming conventions but are not checked:chk_orders_amount_positivepk_users(distinct from the_pkeyindex name)Without validation, these can silently drift from the team's naming convention.
Proposed solution
Extend
fetch_table_naming_resultsandvalidate_naming_resultsto collect and validate named constraints viaInspector.get_check_constraints(),Inspector.get_unique_constraints(), andInspector.get_pk_constraint().Add corresponding class variables to
MigrationNamingMixin(and expose onMigrationTestBase):Scope
New feature — additive, fully backward-compatible (empty or sensible defaults for all new attributes).