Deal Breakers & Full Compatibility Matrix#
← Assimilation hub · Live test fixture: cases/06_unsupported_blockers/
Honesty matters most when evaluating a migration tool. Certain PostgreSQL schema constructs do not fit pgdorm's typed model and migration IR cleanly — and rather than silently dropping constraints or corrupting data, pgdorm audit-schema fails loudly with BLOCKER findings (migratable: false, exit code 3).
What counts as a deal breaker (and your two options)#
When audit-schema reports any BLOCKER finding, you have two clean paths forward:
- Isolate the table (
--ignore-table <name>): Keep that specific legacy/foreign/inherited table outsidepgdorm's managed schema while assimilating the rest of your database. - Refactor before assimilating: Replace classic PostgreSQL
INHERITSwith declarative partitioning (pg.PartitionBy) orpgdormclass-table inheritance, replace non-temporalEXCLUDE USING gistoverlap checks withpg.TemporalPrimaryKey(WITHOUT OVERLAPS), and flatten multi-dimensional arrays or composite columns into normalized tables or typedJsonb[T].
Live blocker example (06_unsupported_blockers)#
Below is a live PostgreSQL schema combining classic INHERITS table inheritance and a non-temporal EXCLUDE USING gist constraint — and the exact audit output pgdorm produces:
CREATE TABLE base_item (
id BIGINT PRIMARY KEY,
label TEXT NOT NULL
);
CREATE TABLE child_item (
extra TEXT
) INHERITS (base_item);
CREATE TABLE bookings (
id BIGINT PRIMARY KEY,
room_no INTEGER NOT NULL,
span DATERANGE NOT NULL,
EXCLUDE USING gist (room_no WITH =, span WITH &&)
);
- Table 'child_item' uses classical PostgreSQL INHERITS ('base_item').
- Table 'bookings' appears plural; assimilate to singular snake_case.
- Table 'base_item' PK is 'id' instead of 'base_item_id'.
- Table 'bookings' PK is 'id' instead of 'bookings_id'.
- Table 'child_item' has no primary key.
- Exclusion constraint 'bookings_room_no_span_excl' on 'bookings': EXCLUDE USING gist (room_no WITH =, span WITH &&)
- Index 'bookings_room_no_span_excl' on 'bookings' (gist, non_btree:gist) will be preserved untouched.
Inspect raw machine-readable audit JSON (tests/integration/migrations/onboarding/cases/06_unsupported_blockers/captured/audit.json)
{
"counts": {
"blocker": 1,
"info": 0,
"migration_required": 4,
"unmanaged": 2
},
"findings": [
{
"auto_fixable": false,
"category": "unsupported",
"code": "PG_TABLE_INHERITANCE",
"doc_anchor": "unsupported-blockers",
"message": "Table 'child_item' uses classical PostgreSQL INHERITS ('base_item').",
"object_kind": "table",
"object_name": "child_item",
"severity": "blocker",
"suggestion": "Flatten or convert to declarative partitioning / CTI before assimilating.",
"table": "child_item"
},
{
"auto_fixable": true,
"category": "naming",
"code": "TABLE_NAME_PLURAL",
"doc_anchor": "table-naming",
"message": "Table 'bookings' appears plural; assimilate to singular snake_case.",
"object_kind": "table",
"object_name": "bookings",
"severity": "migration_required",
"suggestion": "Rename table to singular snake_case via AdoptionMap.",
"table": "bookings"
},
{
"auto_fixable": true,
"category": "primary_key",
"code": "PK_NAME_MISMATCH",
"doc_anchor": "primary-keys-and-serials",
"message": "Table 'base_item' PK is 'id' instead of 'base_item_id'.",
"object_kind": "primary_key",
"object_name": "id",
"severity": "migration_required",
"suggestion": "Rename single int/UUID PK to `<table_name>_id`, or add surrogate PK.",
"table": "base_item"
},
{
"auto_fixable": true,
"category": "primary_key",
"code": "PK_NAME_MISMATCH",
"doc_anchor": "primary-keys-and-serials",
"message": "Table 'bookings' PK is 'id' instead of 'bookings_id'.",
"object_kind": "primary_key",
"object_name": "id",
"severity": "migration_required",
"suggestion": "Rename single int/UUID PK to `<table_name>_id`, or add surrogate PK.",
"table": "bookings"
},
{
"auto_fixable": true,
"category": "primary_key",
"code": "PK_MISSING",
"doc_anchor": "primary-keys-and-serials",
"message": "Table 'child_item' has no primary key.",
"object_kind": "primary_key",
"object_name": "child_item",
"severity": "migration_required",
"suggestion": "Add `<table_name>_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY`.",
"table": "child_item"
},
{
"auto_fixable": false,
"category": "unmanaged",
"code": "EXCLUSION_CONSTRAINT",
"doc_anchor": "unmanaged-objects",
"message": "Exclusion constraint 'bookings_room_no_span_excl' on 'bookings': EXCLUDE USING gist (room_no WITH =, span WITH &&)",
"object_kind": "constraint",
"object_name": "bookings_room_no_span_excl",
"severity": "unmanaged",
"suggestion": "Preserved automatically; replace overlaps with `WITHOUT OVERLAPS` if desired.",
"table": "bookings"
},
{
"auto_fixable": false,
"category": "unmanaged",
"code": "UNMANAGED_INDEX_PRESENT",
"doc_anchor": "unmanaged-objects",
"message": "Index 'bookings_room_no_span_excl' on 'bookings' (gist, non_btree:gist) will be preserved untouched.",
"object_kind": "index",
"object_name": "bookings_room_no_span_excl",
"severity": "unmanaged",
"suggestion": "Preserved automatically; verify expression predicates if columns are renamed.",
"table": "bookings"
}
],
"ignored_tables": [],
"migratable": false,
"schema": "public",
"table_count": 3,
"type_table_candidates": [],
"unmanaged_objects": {
"extensions": [],
"indexes": [
{
"access_method": "gist",
"indexdef": "CREATE INDEX bookings_room_no_span_excl ON public.bookings USING gist (room_no, span)",
"name": "bookings_room_no_span_excl",
"reason": "non_btree:gist",
"table": "bookings"
}
],
"rls_policies": [],
"routines": [],
"triggers": [],
"views": []
},
"workflow_steps": [
{
"detail": "Address every [BLOCKER] finding (or exclude foreign/unsupported tables via --ignore-table).",
"order": 1,
"phase": "pre_ddl",
"summary": "Resolve unsupported schema blockers"
},
{
"detail": "Run `pgdorm scaffold` and `pgdorm adopt-plan` (use `execute_plan_tx` inside a psycopg3 transaction when recreating views/functions atomically).",
"order": 2,
"phase": "ddl",
"summary": "Scaffold models, review AdoptionMap, and execute transactional DDL"
},
{
"detail": "Run `finalize_external()` or `pgdorm upgrade`, then verify `pgdorm drift`.",
"order": 3,
"phase": "post_commit",
"summary": "Run CONCURRENTLY indexes, VALIDATE constraints, and record ledger"
}
]
}
Complete Compatibility & Support Matrix#
This matrix is generated directly from pgdorm.migrate.ONBOARDING_RULES — the exact same rule registry executed by pgdorm audit-schema.
Supported out of the box#
Handled natively by pgdorm models and pgdorm scaffold without schema rewrites.
| Rule code | Severity | Feature / pattern | Recommended action |
|---|---|---|---|
SERIAL_COLUMN |
info |
Legacy SERIAL / sequence nextval(...) default — SERIAL PKs auto-upgrade to pg.identity() (or server_managed=True in bind). |
Assimilate upgrades SERIAL PKs to IDENTITY; bind uses server_managed=True. |
CUSTOM_OR_EXTENSION_TYPE |
info |
Extension, domain, or custom column type — Types like citext, ltree, vector, or PG domains bind via pg.CustomType. |
Scaffold emits Annotated[str, pg.CustomType(pg_type=...)] for review. |
TIMESTAMP_WITHOUT_TZ |
info |
TIMESTAMP WITHOUT TIME ZONE column — Supported natively via pg.Timestamp (plain datetime maps to TIMESTAMPTZ). |
Scaffold emits pg.Col[pg.Timestamp] automatically. |
Auto-migratable during assimilation#
Flagged by pgdorm audit-schema and automatically planned by AdoptionMap + plan_adoption().
| Rule code | Severity | Feature / pattern | Recommended action |
|---|---|---|---|
TABLE_NAME_NON_SNAKE |
blocker |
Non-snake_case or mixed-case table name — Table name is not snake_case (mode='bind' requires singular snake_case). |
Use mode='assimilate' so AdoptionMap renames it, or exclude via ignore_tables. |
TABLE_NAME_BUILTIN_COLLISION |
blocker |
Table class name collides with a Python builtin — PascalCase model name shadows a Python builtin (e.g. ImportError). |
Use mode='assimilate' to map to <name>_record, or exclude via ignore_tables. |
TABLE_NAME_PLURAL |
migration_required |
Plural table name — Table name appears plural (users, order_items); pgdorm models are singular. |
Rename table to singular snake_case via AdoptionMap. |
TABLE_NAME_RESERVED |
migration_required |
Python keyword or reserved identifier — Table or column name collides with a Python keyword (class, from, type). |
Rename table or column to a valid Python identifier via AdoptionMap. |
NON_TYPE_TABLE_ENDS_WITH_TYPE |
migration_required |
Regular entity table ending in _type — The _type suffix is strictly reserved for pg.TypeTable enum lookup tables. |
Either promote to pg.TypeTable or rename the entity table (e.g. *_kind). |
PK_NAME_MISMATCH |
migration_required |
Primary key not named <table_name>_id — Permanent tables declare <table_name>_id so joins auto-emit JOIN ... USING. |
Rename single int/UUID PK to <table_name>_id, or add surrogate PK. |
PK_COMPOSITE |
migration_required |
Composite primary key on permanent table — Junction/entity tables use a surrogate <table_name>_id PK + pg.Unique(...). |
Add surrogate <table_name>_id PK and demote composite PK to pg.Unique(...). |
PK_MISSING |
migration_required |
Table has no primary key — Permanent tables require a <table_name>_id primary key. |
Add <table_name>_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY. |
TYPE_TABLE_CANDIDATE |
info |
Lookup table candidate for pg.TypeTable — Referenced table has an int/UUID PK and unique short text column. |
Review candidate; pass --type-table <table> or as_type_table=True to promote. |
PG_NATIVE_ENUM |
info |
PostgreSQL native CREATE TYPE ... AS ENUM — Zero-DDL Bind binds PG enums via CustomType (no CREATE TYPE DDL). |
Use mode='assimilate' to migrate PG enums into seeded IntEnum pg.TypeTables. |
UNINDEXED_FK |
migration_required |
Foreign key missing a leftmost-prefix B-tree index — pgdorm enforces indexed FKs (auto_index=True) to avoid parent-delete seq scans. |
Assimilation plans online CREATE INDEX CONCURRENTLY for uncovered FKs. |
UNVALIDATED_CONSTRAINT |
migration_required |
Unvalidated NOT VALID constraint — An existing CHECK, FK, or NOT NULL constraint is marked NOT VALID in PG. |
Assimilation schedules online VALIDATE CONSTRAINT under SHARE UPDATE EXCLUSIVE. |
INVALID_INDEX |
migration_required |
Invalid leftover index (indisvalid = false) — Likely left behind by an interrupted CREATE INDEX CONCURRENTLY. |
Assimilation drops the invalid index concurrently before rebuilding. |
Preserved untouched (unmanaged)#
Never altered, dropped, or versioned in _pgdorm; live SQL definitions are exported for review and impact warnings are raised whenever referenced tables/columns rename.
| Rule code | Severity | Feature / pattern | Recommended action |
|---|---|---|---|
FK_ON_UPDATE_ACTION |
info |
Foreign key with non-default ON UPDATE action — pgdorm models ON DELETE actions; ON UPDATE clauses are not currently modeled. |
Matched by signature; review if PK updates rely on ON UPDATE CASCADE. |
DEFERRABLE_CONSTRAINT |
info |
Deferrable constraint (DEFERRABLE) — Constraint deferrability attributes are not modeled on pg.Table. |
Existing constraint is preserved when untouched; recreate manually if altered. |
FUNCTION_OR_PROC_PRESENT |
unmanaged |
Functions and stored procedures (pg_proc) — Stored routines are intentionally excluded from pgdorm.migrate versioning. |
Preserved untouched; review any routine referencing renamed tables or columns. |
TRIGGER_PRESENT |
unmanaged |
User triggers (pg_trigger) — Triggers are intentionally left unmanaged by pgdorm.migrate. |
Preserved untouched; verify trigger function bodies after table/column renames. |
VIEW_PRESENT |
unmanaged |
Views and materialized views — Views are left unmanaged; column renames or type changes may require recreating. | Use the external-TX bridge (psycopg3) to recreate impacted views atomically. |
UNMANAGED_INDEX_PRESENT |
unmanaged |
Non-B-tree (GIN/GiST/BRIN/Hash), expression, or INCLUDE index — Recorded in TableSnapshot.unmanaged_indexes and never dropped by diffing. |
Preserved automatically; verify expression predicates if columns are renamed. |
RLS_POLICY_PRESENT |
unmanaged |
Existing Row-Level Security policies — Existing RLS policies are preserved untouched during schema diffing. | Review policy expressions if referenced columns are renamed. |
EXTENSION_PRESENT |
unmanaged |
Installed PostgreSQL extension — Extension installed inside the app schema; DROP SCHEMA ... CASCADE removes it. | pgdorm creates the extensions its models need (btree_gist) in public. |
LEGACY_MIGRATION_TABLE |
unmanaged |
Third-party migration ledger table — Detected legacy tool ledger (alembic_version, django_migrations, etc.). |
Auto-added to ignore_tables so pgdorm.migrate leaves it untouched. |
EXCLUSION_CONSTRAINT |
unmanaged |
Exclusion constraint (EXCLUDE USING ...) — Arbitrary EXCLUDE USING constraints are preserved untouched during diffing. |
Preserved automatically; replace overlaps with WITHOUT OVERLAPS if desired. |
Unsupported blockers#
Detected as BLOCKER findings (migratable=false, CLI exit code 3). Resolve or isolate with --ignore-table before assimilating.
| Rule code | Severity | Feature / pattern | Recommended action |
|---|---|---|---|
PG_TABLE_INHERITANCE |
blocker |
PostgreSQL classical INHERITS table inheritance — Classical INHERITS is unsupported; pgdorm uses STI/CTI or partitioning. |
Flatten or convert to declarative partitioning / CTI before assimilating. |
FOREIGN_TABLE_PRESENT |
blocker |
Foreign table (FDW / relkind = 'f') — Foreign Data Wrapper tables cannot be migrated by pgdorm.migrate. |
Exclude via --ignore-table or access via a separate read_only=True model. |
COMPOSITE_COLUMN_TYPE |
blocker |
User-defined composite column type — Columns using custom CREATE TYPE ... AS (...) row types are not supported. |
Normalize into columns or JSONB before assimilating. |
MULTIDIM_ARRAY_TYPE |
blocker |
Multi-dimensional PostgreSQL array column — pgdorm binary array codecs support 1-D arrays (T[]), not T[][]. |
Store nested arrays as JSONB or normalize into a child table. |
RESERVED_SCHEMA_PGDORM |
blocker |
Reserved _pgdorm schema — The _pgdorm schema is reserved exclusively for pgdorm's internal ledger. |
Move user tables into another schema (e.g. public or app). |
Reporting an assimilation bug (schema-first TDD)#
Hit a PostgreSQL schema that audit-schema, scaffold, or plan_adoption handles poorly? You don't need to share application code — attach a minimal .sql reproducer modeled on tests/integration/migrations/onboarding/cases/:
-- schema.sql: minimal PostgreSQL DDL reproducing the issue
CREATE TABLE legacy_items (
id BIGSERIAL PRIMARY KEY,
code VARCHAR(32) NOT NULL UNIQUE
);
# case.toml: expected audit + assimilation outcome
expect_migratable = true
expect_findings = ["TABLE_NAME_PLURAL", "PK_NAME_MISMATCH", "SERIAL_COLUMN"]
expect_tables = ["legacy_item"]
Drop a new numbered folder under tests/integration/migrations/onboarding/cases/ and run:
Every case automatically seeds an isolated PostgreSQL schema via psql, runs audit_schema(), scaffolds and executes the generated Python models, compiles and applies the assimilation plan, and asserts check_drift().in_sync.