Skip to content

Latest commit

 

History

History
517 lines (446 loc) · 97.4 KB

capabilities.md

File metadata and controls

517 lines (446 loc) · 97.4 KB

Capabilities and support matrix

One page answering the three questions users actually ask: does pg-sprite support this change?, what is pg-sprite and why does it exist?, and what does pg-sprite deliberately not do? Every operation and object type lands in exactly one of three tiers, and every planned tier-2 item corresponds to a real roadmap item — nothing is vaguely "future work".

This page is the support matrix; the mechanics of each current refusal (what lock the refused form would take, what an operator who accepts a maintenance window can do) live in limitations.md.

Contents

A ✅ marks an implemented capability; the tables below do not show which front door admits it — pg-sprite capabilities does (the migrate: and diff: entries on each operation's attribute line, or front_doors in --json). Every ✅ row also has a maturity: generally available (ga), or preview, which runs only when the run opts in. Today the preview rows are the ones on the copy-and-swap path; the same attribute line of pg-sprite capabilities, or maturity in --json, names each row's. The atomic RLS executor is available through migrate --desired and the Go API. For an existing table, diff shows RLS changes for review without emitting executable SQL; for a missing table, it previews the create with its RLS.

Query the matrix

The marker-delimited regions of this page are generated from pkg/capabilities/capabilities.yaml; the surrounding guidance is hand-written. Run pg-sprite capabilities for a readable listing, or use pg-sprite capabilities --json for automation. Both forms read the embedded YAML data only and do not connect to PostgreSQL. The machine-readable capabilities contract defines the JSON schema and versioning rules. Array order is source order and stable for display, but select rows by id or by field, never by array position.

# Is this one operation supported today? Look a row up by its id.
pg-sprite capabilities --json | jq '.capabilities[] | select(.id == "add-column-no-default-or-constant-default")'

# What is generally available today: supported, and not in preview. A row with
# min_server_major runs only from that PostgreSQL major. ga is not a list of
# statements to run unconditionally: each still needs its own safety flags,
# such as --allow-destructive for DROP COLUMN, which preview's opt-in does not replace.
pg-sprite capabilities --json | jq '.capabilities[] | select(.maturity == "ga")'

# What is supported but in preview, so a run must opt in.
pg-sprite capabilities --json | jq '.capabilities[] | select(.maturity == "preview")'

# All T2 rows.
pg-sprite capabilities --json | jq '.capabilities[] | select(.tier == "t2")'

# What is waiting on the copy engine, across tiers.
pg-sprite capabilities --json | jq '.capabilities[] | select(.engine_path == "copy_and_swap")'

# Everything diff refuses. Query the door you use: RLS changes are review-only
# in diff, but can execute through migrate --desired.
pg-sprite capabilities --json | jq '.capabilities[] | select(.front_doors.diff == "refused")'

# Rows another tool class owns: the ⚪ and 🔵 rows. The ❌ rows name no owner: they have
# no online mechanism pg-sprite will drive (PostgreSQL has none, or the only online form
# is a direct statement the operator runs), so this is not the full out-of-scope set.
pg-sprite capabilities --json | jq '.capabilities[] | select(.owning_tool_class != null)'

What pg-sprite is — and why it exists

pg-sprite is an online schema-change engine for PostgreSQL: it takes one table-shape change, classifies it against the live database, and either executes it through the safest known online pattern under bounded sessions, or refuses with a typed reason. The measure of the tool is not how many object types it models but whether a change it accepts can hurt a production workload. The full positioning is vision.md; how it differs from planners and imperative copy tools by problem class is architecture.md.

This is the Unix design philosophy applied to schema changes — do one thing, and do it perfectly. The one thing is online table-shape change under concurrent load; this whole page is the map of where that one thing ends and another tool's job begins.

Two consequences follow, and they explain most of this page:

  1. Tables and their indexes are the model, by design. Online safety is a readers-and-writers problem, and readers and writers touch tables. Objects with no concurrent-access problem (extensions, functions, grants) are not in scope — not because they are hard, but because there is nothing for an online engine to solve.
  2. A refusal is a feature, not a gap. migrate and its dry-run exit with code 0 only when the change is executable through an online-safe path; a refusal exits 2 with a typed reason. CI can gate on the exit code alone. That contract is only worth something if pg-sprite never executes what it cannot vouch for — see Why typed refusal, not passthrough. The one sanctioned exception keeps the gate honest: a blocking form the operator explicitly accepts runs under bounded budgets and exits 3, never 0, so a gate that fails on any non-zero status stays fail-closed (the full ladder).

The support model: three tiers

Tier Meaning What you see today
T1 — supported today The engine executes the change through an online-safe pattern Execution (or the safer rewritten sequence), exit 0
T2 — planned A known online pattern exists (or requires the copy-and-swap engine); building it is on the roadmap A typed refusal naming the reason, exit 2 — never a silent fallback to a blocking form
T3 — out of scope by design No online-safety problem to solve, solving it belongs to a different tool class, or there is no online mechanism pg-sprite will drive (PostgreSQL has none, or the only online form is a direct statement the operator runs) A typed refusal or a parse-level rejection, with the reason stating why it is not planned

T3 rows carry one of three marks, because they mean different things — and only one of them is a limitation:

  • ⚪ no online-safety problem to solve — the operation does no table scan and no rewrite; at most it takes a brief catalog lock. There is nothing for an online engine to add; run it through owner tooling or psql. Where that brief lock lands on a live table (a trigger, a view swap, a greenfield foreign key), the row says so: the statement queues behind long-running queries and blocks sessions behind it while it waits, so run it under a lock_timeout.
  • 🔵 a different tool class owns it — the job is real but belongs to another kind of tool (data-change runners, provisioning/IaC, convergence planners, expand/contract frameworks). The row's "Online-safety problem?" column names the class to look for.
  • ❌ no online mechanism pg-sprite will drive — PostgreSQL has none, or the only online form is a direct statement the operator runs, so pg-sprite refuses rather than silently run the blocking form. Index maintenance (DROP INDEX, REINDEX) is the second case: the online form is a plain CONCURRENTLY statement, which migrate refuses to wrap and names so you run it directly; for a single-relation plain form, --accept-blocking runs it under budgets and exits 3 (a DROP INDEX also needs --allow-destructive).

Every matrix table carries an "Online-safety problem?" column: "Yes" means there is a readers-and-writers problem for an online engine to solve (pg-sprite solves it, plans to, or — ❌ — nothing can today); "No" states which tool class users should reach for instead.

The invariant: every T2 row is a tracked roadmap item; T3 rows deliberately have none. If a refusal message points at a "planned" capability, that plan exists — otherwise the change is out of scope by design, and this page names the tool class that owns the job; the refusal itself carries the same answer as its class and owner (refusal-classes.md).

The engine path

Tier answers whether pg-sprite stands behind a change; the Engine path column in each matrix table answers how — the route the change takes (or will take) through the engine:

  • native, as-is — the statement is already online-safe (metadata-only, or already the online idiom); executed directly under bounded sessions. The bound is lock_timeout/statement_timeout, except that a concurrent index build may instead run under an explicit caller-owned cancellable context with statement_timeout disabled. That bounds the client call, not the server statement: the executor refuses a context that cannot be cancelled, but a client that dies without cancelling leaves the build running server-side; Tracker.CancelBuild (or an operator's pg_cancel_backend) is the stop path.
  • native, safer sequence — the blocking form is substituted with the equivalent online sequence before execution; the rewrites are catalogued in safer-sequences.md.
  • native, planned flow — a native online pattern exists (or a modeling gap is being closed); the row is a typed refusal until that flow lands, and each such row is a tracked roadmap item.
  • copy-and-swap — the change is a genuine table rewrite and routes to the shadow-copy engine: the changed shape is built as a shadow table, filled and verified, then swapped in under the source's name. The route is in preview: it runs only when the run opens it (migrate --copy-and-swap; CopySwapOptions.Enabled in the library), and is otherwise refused before the route's preflight runs or anything is written (copy-and-swap-refused, cause copy-and-swap-not-enabled); native rows are unaffected. Open, a ✅ row on this path executes; a 🟡 row is a typed refusal (backend-unavailable) for an operation the engine does not carry yet (see optimistic-attempt.md for how the router proves the rewrite). A run on a pool smaller than its copy workers plus two is refused with pool-too-small before it creates anything, from every entry point, the library's schemachange.Runner.Run included (the pool floor).
  • — — no engine path: either the job belongs to another tool class (⚪ / 🔵) or there is no online mechanism pg-sprite will drive (❌): PostgreSQL has none, or the only online form is a direct statement the operator runs.

Path and tier are orthogonal on purpose: a 🟡 row's path says what kind of work lifts the refusal — building a native flow or teaching the copy engine the operation — and a ✅ row's path says whether the engine ran your statement as written, substituted a safer one, or rebuilt the table through copy-and-swap.

The two front doors

Support differs by front door, so the matrix marks the exceptions:

  • Imperative (migrate --alter, migrate --dry-run, lint, suggest): takes one DDL statement, classifies it, and executes the online form — rewriting a blocking statement into its safer sequence where one exists. This door has the broadest coverage.
  • Declarative (diff, pull, desired files, and lint --desired, which runs the desired-file admission offline): compares a desired CREATE TABLE file against the live table. This door depends on the canonical table model, which is deliberately narrower: a table the model cannot fully describe gets a typed refusal rather than a silently lossy description. Today that means tables that are partitions (a partitioned parent is modelled; see the partitioned-tables rows), participate in classic table inheritance, are referenced by foreign keys, are unlogged, carry explicit collations, take defaults from sequences they do not own, or hold two primary key, unique, or exclusion constraints declared the same way.

A table that owns foreign keys is described by the model, so diff plans its foreign-key changes, but desired-state execution refuses them. Export refuses the table unless the caller opts in with schemadiff.RenderOptions.ForeignKeys, which writes each table's own foreign keys and leaves the caller to render every referencing table too. An operation can therefore be T1 imperatively and T2 declaratively — foreign keys are the canonical example.

Support matrix

Editing the matrix: edit ../pkg/capabilities/capabilities.yaml, then run make gen-capabilities; do not edit the generated regions below by hand.

72 operations: 35 supported today (2 of them in preview), 15 planned behind a typed refusal, 17 out of scope by design, and 5 with no online mechanism for pg-sprite to build on.

Status legend: ✅ T1 (supported today and generally available) · ✅ preview T1 (supported today, in preview: the run must opt in) · 🟡 T2 (planned; typed refusal today) · ⚪ T3 (out of scope; no online-safety problem — run directly, or through whatever review the object warrants) · 🔵 T3 (out of scope; a different tool class owns it) · ❌ T3 (out of scope; no online mechanism pg-sprite will drive: PostgreSQL has none, or the only online form is a direct statement the operator runs).

Column changes

Operation Status Engine path Online-safety problem? Behavior and why
ADD COLUMN (no default, a constant default, or a non-volatile default such as now()) ✅ native, as-is Yes Metadata-only / fast default (PG 11+), proven by adding the column to an empty temporary table first; executes instantly under bounded locks. A NOT NULL column with no default, whether NOT NULL is spelled or comes from its domain or an inline PRIMARY KEY, is refused with not-null-without-default when the table holds rows, which PostgreSQL would refuse. An add to a table that has used all 1,600 column numbers, dropped columns included, is refused with column-limit
ADD COLUMN with volatile default (gen_random_uuid(), clock_timestamp(), identity, serial, …) 🟡 copy-and-swap Yes Table rewrite; routes to copy-and-swap, which does not carry a volatile default yet (the shadow fill would have to evaluate the default per row and the stream would have to agree). An identity or serial column is further refused at the shadow build itself with shadow-statement-new-sequence, as a sequence the swap cannot carry to the live table — the engine's guard for library callers that reach the build without this route check — see limitations.md
ADD COLUMN of a domain type with a CHECK or NOT NULL, with or without a default 🟡 copy-and-swap Yes Table rewrite to check every row against the domain; routes to copy-and-swap, which does not carry an added column yet (the shadow fill and the stream would each fill it from the default). A library caller that reaches the shadow build with a domain that refuses NULL and has no default is refused there with shadow-statement-new-column
ADD COLUMN ... GENERATED ... STORED 🟡 copy-and-swap Yes Table rewrite; routes to copy-and-swap, which does not carry stored generated columns yet — the copy must recompute, never copy, them on the shadow table
ALTER COLUMN ... SET EXPRESSION (changed stored generated expression) 🟡 copy-and-swap Yes Planned but not executed. diff shows a changed stored generated expression as one SET EXPRESSION statement of kind set-generated-expression, refused with unsupported-statement, rather than a drop and re-add that would also drop the column's indexes. It recomputes every row under ACCESS EXCLUSIVE, and the statement needs PostgreSQL 17 or later. An expression whose text the file keeps is not a change, even when the file retypes a column it reads: see the retyping row in limitations.md
ADD COLUMN with inline UNIQUE/PRIMARY KEY/REFERENCES/CHECK 🟡 native, planned flow Yes The inline constraint does its index build or validation scan under the ADD COLUMN's ACCESS EXCLUSIVE lock; refused with guidance to add the column first, then build the constraint online
DROP COLUMN ✅ native, as-is Yes Metadata-only; flagged destructive in the plan report. migrate refuses it with destructive-change unless --allow-destructive names the table (migrate --desired refuses a destructive plan whole unless --expect-fingerprint pins the reviewed plan and --allow-destructive names the table); dropping a column and adding it back in one statement is refused with the alter-column-type-in-place guidance. Refused with replica-identity when a replica identity index the drop reaches keys on the column: the table's own, or one on a partition or inheritance child below it unless the statement says ONLY. Refused with dependent-view, naming the views, when a view or materialized view reads the column, on a table the drop reaches. Refused with dependent-policy, naming the policies, when a row-level security policy reads the column, on a table the drop reaches or on another table through a subquery. Refused with dependent-trigger, dependent-publication, dependent-generated-column, or partition-key, naming the objects, when a trigger's UPDATE OF list or WHEN condition names the column, a publication's column list or row filter names it, a generated column reads it, or it is in a partition key, on a table the drop reaches. Refused with cascading-drop when the statement says CASCADE, which would also drop the views and policies that read the column. A trigger whose PL/pgSQL function reads the column, which PostgreSQL records no dependency for and lets the drop break, is named in the decision's trigger_reads with the line that reads it, and a trigger whose function cannot be checked in unchecked_triggers; neither changes the route. A migrate --desired drop reads the object again under the table's lock and refuses with dropped-object-drift, dropping nothing, if its definition is not the one the reviewed plan carried. On a partitioned table it drops the column from the parent and every partition, sub-partitions included, after locking the whole tree: it refuses with dropped-column-partition-key when the column is in the partition key of the parent or of a sub-partitioned partition, and with dropped-column-partition-dependent, naming each object, when a partition carries an index, CHECK or foreign key, statistics object, sequence, or other object of its own on the column, which the parent's plan did not review; copies of the parent's indexes and constraints go with the parent's. On a table with inheritance children it refuses with dropped-object-has-descendants. migrate --alter makes no such partition check beyond the planner's partition-key refusal: the statement the operator wrote drops a partition's own objects on the column, as it drops the table's own.
ALTER COLUMN TYPE, binary-coercible (proven against live column facts) ✅ native, as-is Yes Catalog relabel, e.g. varchar(50) → varchar(100), varchar → text, timestamp(3) → timestamp(6), varbit(8) → varbit(16), cidr → inet, and timestamp → timestamptz in a UTC session for a column no index or foreign key reads, refused with time-zone-drift when the session that runs it is no longer in UTC; refused with dependent-view, naming the views, when a view or materialized view reads the column, and with dependent-policy, naming the policies, when a row-level security policy reads it; refused likewise with dependent-trigger, dependent-publication, dependent-generated-column, or partition-key when a trigger's UPDATE OF list or WHEN condition names it, a publication's column list or row filter names it, a generated column reads it, or it is in a partition key; PostgreSQL itself refuses the change when a rule depends on it — see binary-coercible-type-changes.md A trigger whose PL/pgSQL function reads the column, which PostgreSQL records no dependency for, is named in the decision's trigger_reads with the line that reads it, and a trigger whose function cannot be checked in unchecked_triggers; neither changes the route.
ALTER COLUMN TYPE, general (or with USING) ✅ preview copy-and-swap Yes Table rewrite; runs through copy-and-swap: the changed shape is built as a shadow table, filled in chunks (a USING expression is applied per row), verified, and swapped in under the source's name. The route is in preview and runs only when the run opens it with --copy-and-swap (CopySwapOptions.Enabled); without it the statement is refused with copy-and-swap-refused, cause copy-and-swap-not-enabled, before the route's preflight runs or anything is written, and migrate --dry-run and migrate --desired --dry-run, which take --copy-and-swap as the run does, end in that same refusal without it. Refused with dependent-view, naming the views, when a view or materialized view reads the column, and with dependent-policy, naming the policies, when a row-level security policy reads it, and likewise with dependent-trigger, dependent-publication, dependent-generated-column, or partition-key when a trigger's UPDATE OF list or WHEN condition names it, a publication's column list or row filter names it, a generated column reads it, or it is in a partition key, before the route runs. The route's preflight still refuses table shapes and environments it cannot run against (copy-and-swap-refused); with the route opened, migrate --alter --dry-run runs that preflight under the run's own copy-and-swap flags, writing nothing, and ends in the same refusal, and migrate --desired --dry-run runs it the way the run's admission does, once against the live table under the run's flags, and ends in the run's whole-plan refusal. A USING expression is admitted only when the copy can reproduce it: immutable, naming only the retyped column, not the primary key (shadow-statement-conversion). A statement that also drops a column and adds one of the same name is refused when the copy cannot fill the new column — the primary key, a source identity column, or a column that refuses NULL with no default of its own or its domain's (shadow-statement-readd); a statement that also declares a new identity or serial column, re-added or kept, is refused with shadow-statement-new-sequence — see limitations.md A trigger whose PL/pgSQL function reads the column, which PostgreSQL records no dependency for, is named in the decision's trigger_reads with the line that reads it, and a trigger whose function cannot be checked in unchecked_triggers; neither changes the route.
SET DEFAULT / DROP DEFAULT / DROP NOT NULL ✅ native, as-is Yes Metadata-only. DROP NOT NULL is flagged destructive: migrate refuses it with destructive-change unless --allow-destructive names the table, and migrate --desired runs it only when --expect-fingerprint also pins the reviewed plan. A migrate --desired drop reads the object again under the table's lock and refuses with dropped-object-drift, dropping nothing, if its definition is not the one the reviewed plan carried. A migrate --desired DROP NOT NULL on a partitioned table with partitions, or on a table with inheritance children, refuses with dropped-object-has-descendants: a partition can hold a NOT NULL of its own on the column, which the plan did not review.
SET NOT NULL ✅ native, safer sequence Yes Executed as the native four-step pattern: ADD CONSTRAINT ... CHECK (col IS NOT NULL) NOT VALID → online VALIDATE → SET NOT NULL (catalog flip, PG 12+) → drop the scaffold check
RENAME COLUMN / RENAME TABLE ❌ — Yes — the hazard is to the application, and no SQL exists for migrate to substitute Metadata-only for PostgreSQL but app-breaking across deployed instances: code still using the old name breaks the instant the rename commits, and no safer SQL exists to substitute. Without --force, migrate refuses it as rewrite-required, class by-design, with the expand-contract-column or coordinated-table-rename guidance (and lint reports it at error severity). --force SCHEMA.TABLE runs the rename as submitted under bounded budgets and records the override; above --max-table-size the forced rename is refused as not-native-safe-table-too-large. A desired file cannot express a rename — diff shows a renamed column as a drop and an add
SET TABLESPACE 🟡 copy-and-swap Yes Physical relocation is a rewrite; routes to copy-and-swap, which does not carry a tablespace move yet. A partitioned parent has no storage to move: see the partitioned-parent SET TABLESPACE row

Constraints

Operation Status Engine path Online-safety problem? Behavior and why
ADD PRIMARY KEY / ADD UNIQUE (plain key columns) ✅ native, safer sequence Yes Rewritten to the online sequence: CREATE UNIQUE INDEX CONCURRENTLY → ADD CONSTRAINT ... USING INDEX. The sequence carries the key's INCLUDE columns, NULLS NOT DISTINCT, WITH (...) storage parameters, and index tablespace onto the index, and DEFERRABLE / INITIALLY DEFERRED onto the attach. A storage parameter the sequence cannot render faithfully (a value that is not a plain word, number, or string, a value containing a backslash, or a namespaced parameter name) gets no rewrite and is refused as rewrite-required with the unique-index-then-constraint guidance: build the index with it, then attach it. In a desired file, a new key whose name and index match a valid live unique index takes that index over with ADD CONSTRAINT ... USING INDEX at the key's declared deferrability, instead of a destructive drop and rebuild. Execution reads the index again under the table's lock and refuses with the permanent adopted-index-drift code, attaching nothing, if it was dropped, replaced, or left invalid since planning
ADD PRIMARY KEY / ADD UNIQUE on a partitioned parent ✅ native, planned flow Yes PostgreSQL refuses ADD CONSTRAINT ... USING INDEX on a partitioned table, and a plain ADD CONSTRAINT builds every partition's index under ACCESS EXCLUSIVE on the whole tree, so migrate --alter runs a lone named ADD CONSTRAINT name {PRIMARY KEY | UNIQUE} (columns) on a partitioned parent as the partitioned key build: each partition's unique index is built concurrently and given the constraint with ADD CONSTRAINT ... USING INDEX, then the parent's plain ADD CONSTRAINT adopts them in one brief transaction that builds nothing. The partitions are listed when the run executes, each step commits on its own, an advisory lock refuses a second pg-sprite run on the same table, and the same statement run again resumes from the partition constraints already finished. Refused before anything is created, with unsupported-statement: an unnamed constraint or one with INCLUDE, NULLS NOT DISTINCT, DEFERRABLE, WITH (...), or USING INDEX TABLESPACE (capability-boundary), a key that lacks a partition key column, or a partition key under another collation or equality operator than its column's own (by-design; a constraint cannot name a collation or an operator class, so build a unique index that names the key's with CREATE UNIQUE INDEX, or partition by the column's own collation and default class), a parent that already has a primary key or another object under the name, or a primary key over a column that allows NULL (environmental), and a tree with a sub-partitioned partition (capability-boundary), each only while the run has changed nothing (a stop after a partition's index build began is a failed verdict with the executor's code); the dry run reports the shape, partition key, and sub-partitioned tree refusals too, while the parent and nullable column checks are read only under the build's lock, so for those the dry run reports execute and the apply refuses. The blocking form is never run as submitted: --force meets the unsupported-partitioned-parent refusal instead of the build. A primary key or unique constraint a desired file adds to a partitioned parent takes the same route: diff plans it schema-qualified as the partitioned key build (execution: partitioned-key-build; an unnamed constraint carries the server's default name), migrate --desired runs it as the build with the same verdicts, and a partition's valid unique index of the key's definition, attached to nothing, is given the constraint instead of a new build. A primary key over a column the table allows to be NULL is planned after the SET NOT NULL the file implies. A desired key that lacks a partition key column or names one under another collation or equality operator than the key's, or on a tree with a sub-partitioned partition, refuses the whole plan before its first statement, in migrate --desired --dry-run too, so nothing planned ahead of it commits. A desired key the build does not carry (INCLUDE, NULLS NOT DISTINCT, DEFERRABLE, WITH (...), USING INDEX TABLESPACE) keeps the plain table's plan and is refused with unsupported-partitioned-parent. A live index of the parent under the key's name is not adopted, since the build refuses a parent that has one: the plan drops it, a blocking drop that runs only under --accept-blocking, and then builds the key. See partitioned-index-build-design.md
ADD CHECK / ADD FOREIGN KEY (imperative) ✅ native, safer sequence Yes Rewritten to the online sequence: ADD CONSTRAINT ... NOT VALID (brief metadata lock) → VALIDATE CONSTRAINT (writes keep flowing during the scan). An unnamed constraint is given the name PostgreSQL would choose (<table>_<column>_check, <table>_check, <table>_<columns>_fkey, numbered check1, fkey1, ... past a name another constraint in the schema already holds), because the VALIDATE step has to name it
ADD CONSTRAINT ... NOT VALID / ... USING INDEX / VALIDATE CONSTRAINT ✅ native, as-is Yes Already the online idiom; executed as-is. VALIDATE CONSTRAINT is the idiom only beside operations that take SHARE UPDATE EXCLUSIVE alone, such as another VALIDATE or SET STATISTICS, and such a statement runs under the same validate budget as a lone VALIDATE: beside any other operation in one ALTER TABLE, it scans under that statement's strongest lock, so the statement is refused with rewrite-required until it is split. lint flags a VALIDATE in the same transaction block as an earlier statement that locked the table against reads or writes (validate-in-transaction)
ADD FOREIGN KEY ... NOT VALID on a partitioned parent ✅ native, safer sequence Yes — server version 18 or later Supported on version 18 and later; refused on 14–17 with an environmental class
ADD FOREIGN KEY on a partitioned parent ✅ native, planned flow Yes PostgreSQL 14–17 refuse ADD FOREIGN KEY ... NOT VALID on a partitioned table, and the plain statement validates every partition under SHARE ROW EXCLUSIVE on the whole tree, so on those versions a lone named ADD CONSTRAINT name FOREIGN KEY (columns) REFERENCES schema.table (columns) from migrate --alter, or a foreign key a desired file adds, runs as the partitioned foreign key build: each partition is given the foreign key NOT VALID and validated under SHARE UPDATE EXCLUSIVE while writes continue, then the parent's plain ADD CONSTRAINT adopts them in one brief transaction that holds ACCESS EXCLUSIVE on the referenced table. A rerun resumes from the partitions already finished. On PostgreSQL 18 the ordinary NOT VALID then VALIDATE sequence runs instead (previous row). --force runs the plain statement as written under the brief budgets. Every refusal and failure code, with its class, is in the integration guide's outcomes table, and how a desired plan and a dry run read the build's catalog refusals before anything runs is in partitioned-foreign-key-design.md
EXCLUDE constraints (and unrecognized constraint forms) ❌ — Yes — unsolvable today No online pattern exists in PostgreSQL — the build scans under ACCESS EXCLUSIVE with no NOT VALID/USING INDEX equivalent. Refused; revisit only if PostgreSQL grows one
DROP CONSTRAINT ✅ native, as-is Yes Metadata-only; flagged destructive. migrate refuses it with destructive-change unless --allow-destructive names the table, and migrate --desired runs it only when --expect-fingerprint also pins the reviewed plan. Refused with replica-identity when the constraint owns the table's replica identity index, or the index a partition's is attached under; under REPLICA IDENTITY DEFAULT that is the primary key, while a publication publishes the table's updates or deletes. Refused with cascading-drop when the statement says CASCADE, which would also drop other tables' foreign keys on the constraint. A migrate --desired drop reads the object again under the table's lock and refuses with dropped-object-drift, dropping nothing, if its definition is not the one the reviewed plan carried. On a partitioned table it drops the constraint from the parent and every partition, which hold it only as an inherited or cloned copy (a foreign key's clones included); on a table with inheritance children it refuses with dropped-object-has-descendants.

Indexes

Operation Status Engine path Online-safety problem? Behavior and why
CREATE [UNIQUE] INDEX on a plain table — including partial, expression, covering (INCLUDE), GIN/GiST/BRIN ✅ native, safer sequence Yes Executed as (or rewritten to) CREATE INDEX CONCURRENTLY, with validity verification, typed invalid-index outcomes, and a proven recovery for abandoned leftovers (RebuildAbandonedIndex, or DropAbandonedIndex to remove the leftover without rebuilding; both library-only; runbook)
DROP INDEX ❌ — Yes — migrate --alter does not drive the online CONCURRENTLY form; migrate --desired drives it only for a pinned, acknowledged plan migrate --alter never runs this statement online-safely: the plain form is refused and names DROP INDEX CONCURRENTLY, and the concurrent form is refused as already safe — run it directly against the database. migrate --desired runs an index drop its plan derived as DROP INDEX CONCURRENTLY, never holding the table's lock, when --expect-fingerprint pins the reviewed plan and --allow-destructive names the table; it reads the index again on the dropping session and refuses with the permanent dropped-index-drift code, dropping nothing, if the index is gone, invalid, now backs a constraint, or no longer has the definition the plan carried, and refuses the replica identity index. A desired file that removes or changes an index a foreign key references is refused at plan time with referenced-index, naming the key to drop or change first. A single-index plain DROP INDEX without CASCADE can be run as-is under bounded budgets with --accept-blocking SCHEMA.TABLE plus --allow-destructive SCHEMA.TABLE for the loss (exit 3, never 0; without the second acknowledgement it is refused with destructive-change); --accept-blocking checks the replica identity under the table's lock and refuses the drop as unsupported-statement, naming the identity index. diff reports an index to remove as a destructive DROP INDEX and its note that migrate will run DROP INDEX CONCURRENTLY holds for migrate --desired under the pin and acknowledgement above, not for migrate --alter. diff refuses dropping the table's replica identity index, or one a partition's is attached under, with replica-identity. plan and lint refuse DROP INDEX … CASCADE with cascading-drop, since DROP INDEX CONCURRENTLY does not accept CASCADE. An index of a partitioned table has no concurrent form: PostgreSQL rejects DROP INDEX CONCURRENTLY for it in every supported version, and a partition's own index cannot be dropped alone. diff therefore refuses such a drop with unsupported-partitioned-parent (class by-design, blocking_passthrough_eligible: true; preflight cause parent-concurrent-index-drop), and offers no concurrent rewrite; the statement carries the plain DROP INDEX as its exec_sql with execution: blocking-index-drop, which the fingerprint covers. migrate --desired runs it only when --expect-fingerprint pins the reviewed plan and --allow-destructive and --accept-blocking both name the table, with an explicit --statement-timeout longer than --lock-timeout: in one engine-owned transaction it requests the parent's lock under the lock budget (an exhausted budget refuses, nothing dropped), reads the index again (dropped-index-drift if it changed), drops it, and reads back that every partition's index went with it; the run ends executed-without-online-safety (exit 3). Without --accept-blocking the plan is refused with destructive-change, the detail naming the flags. migrate --alter reads the index's kind from the catalog before it refuses a single-index DROP INDEX (and so does its --dry-run): for a partitioned index both the plain and the CONCURRENTLY form are refused with that same reason and cause, with no safer_idiom, and the detail names the bounded path. The drop is the plain DROP INDEX under migrate --alter --accept-blocking SCHEMA.TABLE --allow-destructive SCHEMA.TABLE (exit 3), which takes ACCESS EXCLUSIVE on the parent, every partition, and every partition's index for as long as the drop runs, and its verdict says so; the CONCURRENTLY form stays refused under those flags. A partition's index attached under a parent index is refused in either form, flags or not, as unsupported-statement (class by-design), naming the root partitioned index to drop instead. When the index it comes down to is owned by a primary key, unique, or exclusion constraint, the drop is refused the same way, naming the ALTER TABLE ... DROP CONSTRAINT that removes it
REINDEX ❌ — Yes — the online form is a direct CONCURRENTLY statement that migrate does not drive migrate never runs this statement online-safely: the plain form is refused and names REINDEX ... CONCURRENTLY, and the concurrent form is refused as already safe — run it directly against the database. A plain REINDEX INDEX or REINDEX TABLE can be run as-is under bounded budgets with --accept-blocking SCHEMA.TABLE (exit 3, never 0). REINDEX SCHEMA, DATABASE, and SYSTEM stay refused. A desired schema cannot express a reindex, so diff never produces one
ALTER INDEX ... RENAME TO ✅ native, as-is Yes Metadata-only: application SQL names tables and columns, not indexes. migrate resolves the index's owning table from the catalog, preflights and privilege-checks that table, and runs the rename under the brief budgets after locking the table in SHARE UPDATE EXCLUSIVE and re-checking that the name is still a plain index of it, then confirms before the commit that the index now carrying the new name is the one it checked, since the rename locks only the index and another session can move the name meanwhile (else the permanent renamed-index-drift code, nothing renamed — ALTER INDEX ... RENAME would also rename a table). An index that backs a primary-key, unique, or exclusion constraint renames the constraint, which ON CONFLICT ON CONSTRAINT names, so it is refused as rewrite-required (app-breaking-rename, guidance coordinated-constraint-rename); --force does not apply to an index rename. It changes only the catalog, so the table-size guard does not refuse it on a large table. Offline lint cannot tell the two kinds of index apart and reports neither. A desired file cannot express a rename
Index build on a partitioned parent ✅ native, planned flow Yes PostgreSQL has no parent-level CONCURRENTLY, so a CREATE INDEX on a partitioned parent runs as the partition-aware build: CREATE INDEX ON ONLY the parent, then CREATE INDEX CONCURRENTLY on each partition, then ATTACH PARTITION. The partitions are listed when the run executes, each step commits on its own, the parent's ON ONLY step blocks writers for one catalog insert, and an advisory lock refuses a second pg-sprite run on the same table. The same statement run again resumes from the invalid parent index and the partition indexes already built, and migrate --desired plans that same CREATE INDEX when the live parent carries an invalid index with the desired definition. It needs a named index, no IF NOT EXISTS, and no TABLESPACE, which would place the parent's index and not the partitions'; a unique index must contain the partition key of every partitioned table in the tree, under each key's collation and equality operator; one that does not is refused (unsupported-statement, by-design) before anything is created, in --dry-run too. The blocking form is never run as submitted: --force does not bypass that, and --accept-blocking does not reach it. See partitioned-index-build-design.md
ADD CONSTRAINT ... USING INDEX on a partitioned parent ❌ — Yes — unsolvable today PostgreSQL does not support adopting an index on a partitioned parent in any supported version; refused before execution

Partitioned tables

Operation Status Engine path Online-safety problem? Behavior and why
CREATE TABLE ... PARTITION OF 🟡 native, planned flow Yes Typed refusal at both doors: the imperative door does not take CREATE TABLE, and the declarative create path refuses the form at plan time and re-checks it at apply — attaching a partition takes a brief ACCESS EXCLUSIVE on the parent, which the greenfield absence proof does not cover. A desired file for a partition that already exists is refused before planning builds anything, since the scratch build would attach to the live parent, and a desired file that declares several partitions, or a parent with its partitions, is refused at parse as a capability-boundary. The partition-aware flow is planned
ATTACH PARTITION ✅ native, planned flow Yes Run as written, the attach scans the new table under ACCESS EXCLUSIVE to validate its bound and builds the parent's indexes on it, so migrate --alter runs a lone ATTACH PARTITION ... FOR VALUES as the online attach instead: while writes continue, the table is given a validated CHECK proving the bound, the parent's CHECK constraints and NOT NULLs, the parent's indexes built concurrently (a unique one backing its constraint through USING INDEX), and each of the parent's foreign keys, validated; then the ATTACH runs in one brief transaction that scans and builds nothing, and the proof CHECK is dropped. Each step commits on its own, and running the same statement again resumes, or finds the table attached and changes nothing. A row outside the bound fails the run with nothing attached. A parent with a DEFAULT partition is refused (unsupported-statement, capability-boundary) before anything runs, since excluding the bound from it refuses writes inside the bound until the attach; an ATTACH PARTITION ... DEFAULT stays rewrite-required. --force SCHEMA.TABLE runs the blocking ATTACH PARTITION as submitted under bounded budgets and records the override. A desired schema cannot express an attach, so diff never produces one
DETACH PARTITION [CONCURRENTLY] ✅ native, safer sequence Yes The plain form is rewritten to DETACH PARTITION ... CONCURRENTLY, which takes SHARE UPDATE EXCLUSIVE on the table, so reads and writes of the other partitions keep running. It runs outside a transaction block under the brief budgets: --lock-timeout bounds each lock wait, the wait for transactions that still read the partition through the table included, and --statement-timeout the whole statement. Flagged destructive, since the partition's rows leave the table: migrate refuses it with destructive-change unless --allow-destructive names the table. A detach that stops after its first transaction committed fails with partition-detach-interrupted and leaves the partition detach-pending; running the same statement again finishes it with DETACH PARTITION ... FINALIZE. A rerun that finds the partition already a table of its own with the table's columns, because an earlier run or a detach the server finished after its client went away detached it, runs nothing and exits 0 with already_detached: true; a same-named table with those columns that never was a partition gets the same verdict, since PostgreSQL keeps no record of a finished detach. PostgreSQL detaches one partition of a table at a time, so while another partition is detach-pending the detach fails with partition-detach-pending before anything runs, naming that partition and its FINALIZE. PostgreSQL refuses a concurrent detach from a table with a DEFAULT partition, so both forms are refused there (unsupported-statement, by-design, in --dry-run too) before anything runs; --force SCHEMA.TABLE runs the plain DETACH PARTITION as submitted under bounded budgets, taking ACCESS EXCLUSIVE on the table and the partition. DETACH PARTITION ... FINALIZE itself is refused with unsupported-statement: rerun the statement that started the detach. A desired schema cannot express a detach, so diff never produces one
SET TABLESPACE on a partitioned parent ✅ native, as-is Yes Metadata-only: a partitioned parent has no storage, so PostgreSQL records the tablespace as the default for partitions created later, under a brief ACCESS EXCLUSIVE on the parent alone, and moves no existing partition or index. Runs as written under bounded locks. Moving an existing partition is a SET TABLESPACE on that partition, a rewrite refused as in the SET TABLESPACE row. ALTER INDEX ... SET TABLESPACE is not taken by the imperative front door. A desired file does not express a table's tablespace, so diff never produces one
Partitioned parents in the declarative model ✅ native, as-is Yes The model carries the parent's partition key. pull exports a parent as CREATE TABLE ... PARTITION BY with its indexes as plain CREATE INDEX statements on the parent (no ON ONLY), and diff of that file against the same parent plans no changes; migrate --desired runs a parent's in-place changes and creates a missing PARTITION BY parent. A different partition key is a typed refusal, and a new index on an existing parent runs as the partitioned index build, under the restrictions of the index-build row. Partitions, their bounds, and the partition topology are not modeled and stay owned outside the desired file: pull skips partitions and a desired file for one is refused. Export refuses a parent whose index is not attached on every partition, and a parent with row security
Partitioned tables in copy-and-swap 🟡 copy-and-swap Yes Root-vs-leaf publication semantics and per-partition swap; the copy-and-swap preflight refuses a partitioned parent, a partition, or a member of an inheritance tree (copy-and-swap-partitioned), and migrate --alter --dry-run and migrate --desired --dry-run with --copy-and-swap, which run that preflight, end in that same refusal (copy-and-swap-unlogged or copy-and-swap-force-rls instead when the table is also UNLOGGED or forces row security, which the preflight decides first); the plan diff prints still routes the change as execute, since it does not read the route's preflight

The declarative model (desired files, diff, pull)

Table shape Status Engine path Online-safety problem? Behavior and why
Plain tables + their indexes ✅ native, as-is Yes diff, pull, and desired-file rendering round-trip the canonical model. The model carries each index's validity (pg_index.indisvalid): on a plain table an invalid entry is a concurrent build that did not finish — abandoned, or still running — so a live entry with the desired name and definition does not deliver the desired index, and diff plans it as a create-index change. diff never emits a drop for an invalid entry, whatever the desired file says about its name: a plain DROP INDEX blocks the table and cannot tell abandoned debris from a build still in progress. Every invalid entry the diff observes and leaves in place is named on the plan report as an advisory (invalid-index-rebuild when the desired file names it, invalid-index-undeclared when it does not), outside the statements and the fingerprint, so an empty plan over such a table reads as 'no changes to run' rather than converged. A pulled baseline leaves such an entry out, since the table does not deliver it, and schemadiff.UnfinishedBuilds lists what was left out; the baseline re-diffs to zero with the invalid-index-undeclared advisory. On a partitioned parent an invalid index means unattached partition indexes, not an unfinished build, so validity plays no part in the parent's comparison
A live check constraint or foreign key left NOT VALID ✅ native, as-is Yes The model carries each constraint's validity (pg_constraint.convalidated). A live constraint left NOT VALID with the desired definition, which an interrupted online add leaves behind, plans as one VALIDATE CONSTRAINT statement (validate-constraint), which scans under SHARE UPDATE EXCLUSIVE while writes keep flowing, instead of a destructive drop and re-add. The statement names only the constraint, so execution reads the constraint again under that same lock and refuses with the permanent validated-constraint-drift code, validating nothing, if it was dropped or replaced under the same name since planning. A foreign key plans as validate-foreign-key and runs the same way. CREATE TABLE ignores NOT VALID, so a desired file cannot declare it: for a check constraint, pull renders the validated definition, and the baseline re-diffs to that one validation rather than to zero. For a foreign key, a caller that renders foreign keys (RenderOptions.ForeignKeys) gets the validated definition the same way
A constraint whose definition changes under the same name ✅ native, safer sequence Yes The old constraint keeps enforcing until the statement that installs the new one removes it, so the table never goes without the rule. A primary key or unique constraint builds its new index CONCURRENTLY as <name>_new, then one ALTER TABLE drops the old constraint and adds the new one USING INDEX, which renames the index to the constraint's name; a failed build leaves the old constraint in place and names the invalid index to drop. A check constraint is dropped and added NOT VALID in one ALTER TABLE, then validated by its own VALIDATE CONSTRAINT, which scans under SHARE UPDATE EXCLUSIVE; if existing rows break the new rule, the validation fails and the new rule stays NOT VALID, checking every new write. Execution checks the dropped constraint, the adopted index, and the validated constraint against the plan under the statement's own lock. A run that stopped after the build is picked up there: a valid <name>_new with the desired definition is swapped in, not built again. When <name>_new is otherwise taken by a desired or live object, the plan refuses with replacement-index-name. For an unfinished <name>_new an earlier attempt left, the refusal names the DROP INDEX CONCURRENTLY to run before planning again. The plan checks the name against the table's own objects; a relation elsewhere in the schema that holds it fails the build with 42P07 before the old constraint is touched. A plan that would drop a primary key or unique constraint a foreign key references, whether to replace it in place, to drop and re-add it, or because the file removes it, is refused at plan time with referenced-index, naming the foreign key to drop or change first, since PostgreSQL does not drop a key a foreign key depends on; a foreign key on the same table that the plan drops first no longer holds the key. A foreign key is replaced the same way as a check constraint: one destructive ALTER TABLE drops the old key and adds the new one NOT VALID, then VALIDATE CONSTRAINT checks the rows. A key or foreign key on a partitioned table, a change of constraint kind, and a diff that also retypes a column, or drops one beside an added column that may rewrite the table keep the drop and re-add, since the server refuses USING INDEX and a NOT VALID foreign key on a partitioned table; a check constraint on a partitioned table is replaced in place like any other, its NOT VALID add reaching every partition; a diff that only drops a column replaces the constraint first and drops the column last. Where the drop and re-add stays, for a foreign key on a partitioned table or beside a retype, or in a file that drops a column beside an added column that may rewrite the table, the drop of the foreign key is refused with declarative-foreign-key (see foreign keys a desired file no longer declares). A primary key replaced in place on a table whose diff also drops a NOT NULL it covered is swapped first, and the NOT NULL is dropped after the swap, since the old key owns its columns' NOT NULL until it is dropped
An index whose definition changes under the same name ✅ native, safer sequence Yes A standalone index whose definition changes under the same name is replaced, never dropped first. Its new definition is built CONCURRENTLY as <name>_new while the old index keeps serving reads and, for a unique index, keeps rejecting duplicates. Once the build is valid, DROP INDEX CONCURRENTLY removes the old index, and ALTER INDEX ... RENAME TO (rename-index) gives the new one its name, so the table has an index with the desired definition before the old one goes; the drop stays destructive, since it removes whatever the desired definition no longer asks for. The drop carries replaced_by, naming the index that replaces it, and reads that index again right before it runs: if it is gone, invalid, or rebuilt with another definition, the drop refuses with replacement-index-drift and the old index stays. A failed build leaves the old index in place and names the invalid <name>_new to clear. A run that stopped part-way resumes where it stopped: a valid <name>_new with the desired definition is not built again, and when the old index is already gone the plan is the rename alone. When <name>_new is taken by another index, or by a desired or live constraint, the plan refuses with replacement-index-name. So it does when the old index is invalid beside a valid <name>_new with the desired definition, which an interrupted DROP INDEX CONCURRENTLY of the old index leaves: the refusal names that drop, and the next plan is the rename alone. An index a foreign key references is refused with referenced-index, naming the key, since PostgreSQL does not drop an index a key depends on. A partitioned table's index is replaced in the same order: the new definition runs as the partitioned index build under <name>_new, each partition's index built concurrently and attached, while the old index keeps enforcing. The old index's drop is the plain DROP INDEX (blocking-index-drop), PostgreSQL's only drop for it; it is catalog-only and runs once the build is valid, and a run that does not accept its blocking lock executes none of the plan, the build included. The rename also renames each partition index the build named after <name>_new, so the same index can be replaced again. A diff that also retypes a column, or drops one beside an added column that may rewrite the table, keeps the drop and rebuild; a diff that only drops a column replaces the index first and drops the column last
An index, unique constraint, or rule that moves to another name ✅ native, safer sequence Yes A desired index whose definition matches a live index's except for its name is renamed in the catalog with ALTER INDEX ... RENAME TO (rename-index), so the index keeps serving and, for a unique index, keeps rejecting duplicates; nothing is dropped or built. An invalid live index or an unfinished build is never renamed. Execution reads the index again under the table's SHARE UPDATE EXCLUSIVE lock and refuses with renamed-index-drift, renaming nothing, if it now backs a constraint or no longer has the definition the plan matched it by. On a partitioned table, each partition index that carries the name the partitioned index build derived from the old name is renamed with it, in the same transaction, so a later build under the new name finds those names free; a partition index under a name of its own keeps it, and when another relation already holds a derived name the rename refuses with renamed-index-drift, renaming nothing. When a uniqueness or a rule moves to another name or another kind of object, such as a unique constraint declared again as a unique index or a check constraint under a new name, the plan builds or adds the replacement first and drops the old object after it: a build that fails, such as a unique index the existing rows break, leaves the old object enforcing. The same holds when the replacement keeps a live name and only its definition changes, such as a plain index the file makes unique. Under the same name, the new index is built as <name>_new first: a unique constraint the file declares as a standalone index is dropped once the build is valid, and the index renamed to its name; a standalone index the file declares as a unique constraint is dropped with DROP INDEX CONCURRENTLY, and the constraint takes over the build with ADD CONSTRAINT ... USING INDEX. Either drop reads <name>_new again first and refuses with replacement-index-drift if it is gone, invalid, or rebuilt. A plan that also drops a column drops it last, after every replacement holds, since the column takes the old indexes and constraints that read it with it. A plan that also retypes a column, or drops one beside an added column that may rewrite the table, keeps the drops first. An index or unique constraint the file drops in favour of another index or key that answers all its lookups, such as a wider index, a key on the same columns, or a plain index where the file relaxes a unique one, waits for that build when the plan builds it, and the drop names it in lookups_kept_by; one whose lookups an index the live table keeps already serves drops first and names that index. A primary key under a new name is swapped in like a changed one, since a table has only one: its index builds under a temporary name while the old key keeps rejecting duplicates, then one statement drops the old key and attaches the index. A unique or primary-key constraint under a new name is not renamed in place. Two shapes are refused at plan time, because the old index would go before its rule is held elsewhere: a new constraint that takes the name of a live index the file renames (renamed-index-name), and a new constraint that takes the name of a live unique index whose key another unique index the plan builds also makes unique, with or without a predicate (moved-unique-rule). Each lands as two changes: the rename or the new index first, then the constraint
Unnamed check constraints whose generated names differ from the live table's ✅ native, as-is Yes PostgreSQL names an unnamed check constraint <table>_<column>_check when it reads exactly one column and <table>_check otherwise, and adds a number (<table>_check1, ...) when another constraint in the schema already holds that name, so a table built by a history of statements and the same table built from one desired file can hold identical checks under shifted names. A check the desired file declares without a name is matched to a live check constraint by definition rather than by name, so a table that differs only in that numbering plans no changes instead of dropping and re-adding every shifted check. A live check whose name the file states is never matched to an unnamed one. An unnamed check with no live match is added under its generated name, or under the next free number when a matched check holds that name; when the next number would need the server's truncation to fit 63 bytes, the plan refuses with ErrUnsupportedChange. When a LIKE clause could copy constraints, every check keeps name matching
Classic table inheritance (INHERITS) 🟡 native, planned flow Yes Typed refusal for both parents and children: the model cannot express inheritance edges, and flattening inherited columns would produce a silently lossy baseline. A desired file that declares INHERITS is refused before planning builds anything, since the scratch build would lock the live parent and add an inheritance edge to it
Foreign keys a desired file adds, on a live table or a new one ✅ native, safer sequence Yes A desired file may declare a foreign key to an unqualified table that exists in the target schema, or to its own table. A reference may also name a table in another schema when the caller lists that schema in ForeignKeySchemas (diffplan.Request, migrate.DesiredRequest, and RenderOptions for export; --foreign-key-schema on diff and migrate --desired). The list is default-deny: a schema it leaves out, the table's own schema, and a schema on the path the table is read under (public behind any other schema) are refused (ErrForeignKeySchemaNotAllowed), and a system schema (pg_catalog, information_schema, pg_toast, pg_temp_*, pg_toast_temp_*) is refused at parse even when listed (ErrForeignKeyIntoSystemSchema). Planning binds such a reference to an empty copy of the live table in a scratch schema of its own, so a referenced column that is missing or has no unique key fails the plan with the server's cause, and the live table in the other schema takes only ACCESS SHARE; the run takes the same locks on it as on a referenced table in the target schema, under the same lock budget and retries. diff shows a matching foreign key as no change. A key the file adds to a live table plans as add-foreign-key and runs as two autocommitted steps: ADD CONSTRAINT ... NOT VALID, a brief SHARE ROW EXCLUSIVE lock on both tables that checks no existing row, then VALIDATE CONSTRAINT, which scans under SHARE UPDATE EXCLUSIVE while writes keep flowing. A row that breaks the key fails the validation with the key left NOT VALID, still enforced for new writes; once the rows are fixed, the next plan is that one validation. On a partitioned table before PostgreSQL 18 the key plans and runs as the partitioned foreign key build instead (see the ADD FOREIGN KEY on a partitioned parent row). A CREATE TABLE that declares a foreign key runs as written, since the new table is empty, under the same brief lock budget as every create. Planning binds each reference to an empty scratch copy of the live table, which needs SELECT on it, so planning takes only ACCESS SHARE on the live referenced table. Export refuses both sides by default. A caller that opts in with RenderOptions.ForeignKeys gets each table's own foreign keys written out, and must render the referencing tables too, because an incoming FK lives in the referencing table's file. Export still refuses an FK into a schema RenderOptions.ForeignKeySchemas does not list, an FK from a table to itself whose referenced columns have no immediate primary key or UNIQUE constraint (only a standalone unique index, or only a deferrable constraint beside one), and an FK on a table rendered with RenderOptions.RowSecurity (statement.ErrRowSecurityForeignKey)
Foreign keys a desired file no longer declares, or declares differently ✅ native, as-is Yes A live foreign key the desired file leaves out plans as a drop-foreign-key statement, flagged destructive: migrate --desired runs it only when --allow-destructive names the table and --expect-fingerprint pins the reviewed plan. The drop changes only the catalog, but it takes ACCESS EXCLUSIVE on both the table and the referenced table, under the brief lock budget, and re-reads the key's definition under that lock, so a key replaced under the name since the plan is refused with dropped-object-drift. A live key into a schema ForeignKeySchemas does not list, or a key from a table to itself whose referenced columns are unique only through a standalone unique index, cannot be declared, so its drop is refused with declarative-foreign-key, and migrate --alter removes it. A key into a listed schema drops like any other, taking ACCESS EXCLUSIVE on the table in that schema under the brief lock budget. A key the file moves to a new name is added and validated before the old one is dropped. A validation that fails leaves both keys: the old one valid, and the new one NOT VALID but checking every new write. Once the rows are fixed, the next plan validates the new key and drops the old one; a file that takes the new key out plans its drop instead. A key changed under the same name is replaced by one destructive ALTER TABLE that drops it and adds the new definition NOT VALID, so every write stays checked by one key or the other, and then validated; a validation that fails leaves the new key NOT VALID, checking every new write, and the next plan validates it once the rows are fixed. On a partitioned table the old key would be dropped before the new one is added, leaving writes checked against no key in between, so that drop is refused with declarative-foreign-key; declaring the changed key under a new name adds it first. The same drop is refused in a plan that adds a foreign key and also retypes a column, or drops one beside an added column that may rewrite the table, since that plan keeps its drops first
Unlogged tables 🟡 native, planned flow Yes Typed refusal: persistence is not modeled, converging it (SET LOGGED) is a full rewrite, and rendering the table as plain CREATE TABLE would silently change crash-safety
Explicit column collations 🟡 native, planned flow Yes Exported and compared, not converged. pull writes a column's collation as a schema-qualified COLLATE clause, and a file that keeps it plans the table's other changes. A collation delta is a typed refusal: converging it rewrites the column and rebuilds its indexes
Table storage parameters (WITH (fillfactor = ...), toast.*) ⚪ — No — owner tooling (ALTER TABLE ... SET (...), then declare the result in the file) Modeled, exported, and compared, but not converged. pull writes a table's storage parameters, its TOAST table's included, back as a WITH clause, and a table whose file declares the live parameters plans the rest of its changes normally. A difference in either direction is a typed refusal from diff and migrate --desired (no-online-safety-problem, owner direct-operator, exit 2): a parameter the file declares is never reported as applied, and a tuned live parameter the file omits is never reported as matching. A table with no column that needs a TOAST table has none, and the server discards toast.* parameters set on it, so a file that declares one alongside a newly added text-like column refuses too
Column compression and storage (COMPRESSION, and STORAGE on PostgreSQL 16+) ⚪ — No — owner tooling (ALTER TABLE ... ALTER COLUMN ... SET COMPRESSION or SET STORAGE, then declare the result in the file) Modeled, exported, and compared, but not converged. pull writes a column's compression method, and its storage mode where it differs from the type's default, and a column the plan adds carries both. A difference in either direction is a typed refusal from diff and migrate --desired (column-storage, owner direct-operator, exit 2) that names the clause to declare or remove. A column the file also retypes is judged by what ALTER COLUMN ... TYPE leaves: the type change sets the storage mode and the compression method back to the new type's defaults, so a retype with neither clause plans normally, and a clause the file declares is refused with the one statement that changes the type and sets it. Before PostgreSQL 16 no column definition can declare a storage mode, so a live column's mode is neither read nor compared there
Identity and serial sequences declared away from the defaults (START WITH, MAXVALUE, ...) ⚪ — No — owner tooling (ALTER TABLE ... ALTER COLUMN ... SET ..., then declare the result in the file) Modeled and compared, but not converged. An identity's declaration round-trips: pull writes it as the column's options clause, an added identity column carries it, and a file that states the live declaration plans the rest of its changes normally, while a difference in either direction is a typed refusal from diff and migrate --desired (no-online-safety-problem, owner direct-operator, exit 2). A serial's declaration cannot be stated by the serial shorthand, so export refuses a serial whose sequence is declared otherwise, including an integer serial whose column was widened to bigint while its sequence stayed integer. A sequence's current position is data, not schema, and is never compared
Virtual generated columns (PostgreSQL 18+) 🟡 native, planned flow Yes Typed refusal: the desired-file grammar cannot declare VIRTUAL, export refuses a live virtual column, and a desired file that declares it any other way fails the diff, so a virtual expression is never converged as a column default
Columns whose default uses a sequence the column does not own 🟡 native, planned flow Yes Typed refusal: in a desired-state model that sequence exists only inside the scratch transaction, so no derived plan can reference it. Column-owned (serial-style) sequences are fine
Greenfield CREATE TABLE apply (the table does not exist yet — a fresh database or a new table in a live one) ✅ native, as-is Yes — a REFERENCES clause takes a brief SHARE ROW EXCLUSIVE on each referenced live table, under the same lock budget as the CREATE TABLE, so a busy referenced table makes the step time out and retry rather than queue writes behind it Desired-state execution creates the table: CheckTableAbsent verifies the table relation and composite-type name are free, the executor verifies every relation name the desired file states (explicit index names and first-choice constraint-index and column-sequence names) is free in the schema, and CheckCreatePrivileges verifies the role can create there. It then runs the CREATE TABLE and index builds as brief bounded steps under the engine's budgets. An occupied claimed name is a typed create-collision refusal before execution — drop or rename the occupant, name a constraint's index explicitly, or for a sequence use an explicitly named sequence or a non-serial column. Duplicate-name SQLSTATEs backstop races for explicit names; for server-chosen names, the probe narrows the race to the time-of-check window, and after the CREATE TABLE commits the executor reads the constraint-index and sequence names the table actually owns and compares them against the claimed first-choice names — a name taken inside the window makes the server pick a suffixed replacement, which surfaces as a typed create-name-mismatch failure at step 1 with the born table left in place for an operator to rename the relation or drop, then re-diff (a read of the owned names that does not complete is the same step-1 failure as create-names-unverified, never a pass). PARTITION OF, INHERITS, LIKE, OF, IF NOT EXISTS, and in-set duplicate names refuse at plan time and are re-checked at apply, while CONCURRENTLY is refused upstream at desired-file parse and re-checked at admission as defense in depth
Extension types, functions, and operators named unqualified in a desired file (such as citext installed in an extensions schema) ✅ native, as-is Yes A desired file resolves names against the target schema and public only, so an extension installed elsewhere is named qualified (extensions.citext) unless --extension-schema (Go: DesiredSchema.WithExtensionSchemas) names its schema. Those schemas are searched after the target schema and public when the scratch build and the create path run the file, and never shadow a name either one defines. The model is introspected without them, so each such object prints qualified on both sides, and every planned statement on an existing table names the object it resolved to. A table that does not exist yet is created from the file's own statements under the same search path; the plan report lists the schemas in extension_schemas, its fingerprint covers them, and diff --sql sets that search path before the create. Opt-in, because with more schemas searched an unqualified function call can resolve to a different overload. In a row-security file the schemas apply to the table definition only (Go: DesiredWithRowSecurity.WithExtensionSchemas), and a missing table's create preview lists them in extension_schemas; policy expressions still resolve nothing but the table and the built-ins, so they name every such object qualified. An object in a listed schema must belong to an extension however the file names it, bare or qualified: a table whose column type, default, index, constraint or policy uses an application's own object there is refused before anything runs, at plan and at create, so move that object out of the schema or stop listing the schema. migrate --desired reports the plan's refusal as unsupported-statement (by-design).

Types and non-table objects

Object / operation Status Engine path Online-safety problem? Behavior and why
Enum-typed columns on plain tables ✅ native, as-is Yes An enum column is an ordinary column to both front doors: adding one (with a constant default it is catalog-only), changing its default, and indexing it run natively, and a desired file can create a table with one. A desired file names an enum in the table's schema or public bare; introspection renders the live column through format_type, so the file and the live table compare equal and a rerun plans nothing. A desired enum type file creates the enum type when the schema lacks it and adds the labels it later lists, and migrate takes CREATE TYPE ... AS ENUM and ALTER TYPE ... ADD VALUE directly. Retyping a column to or from an enum rewrites the table and runs on copy-and-swap (preview, opt-in)
ALTER TYPE ... ADD VALUE ✅ native, as-is Yes Metadata-only: the statement writes one pg_enum row under a lock on the type alone, so no table that uses the type is locked, scanned, or rewritten, and reads and writes on those tables carry on while it runs. It waits only for another session altering the same type, under the brief budgets with lock-timeout retry. BEFORE, AFTER, and IF NOT EXISTS run as written; a position next to the empty label is refused as unsupported-statement, since the parse tree cannot carry it. migrate resolves the type on the session search_path, checks that it is an enum, that the role has USAGE on a schema the name spells, and that the role is a member of the type's owning role (else insufficient-privileges), pins the attempt's search_path to the type's schema, and confirms before the commit that every label the transaction wrote belongs to that type, or, when IF NOT EXISTS wrote nothing, that the name still resolves to it, since ALTER TYPE ... RENAME does not wait for the lock and another session can move the name meanwhile (else the permanent enum-type-drift code, nothing added). A statement that meets a label the type already carries, or a BEFORE or AFTER label the type no longer carries, returns the permanent enum-label-exists or enum-neighbor-missing code, nothing added. Sessions can use the new value once it commits. --force, --allow-destructive, and the copy-and-swap acknowledgements do not apply. A desired enum type file holds one unqualified CREATE TYPE ... AS ENUM; diff plans an ADD VALUE (kind add-enum-value) for each label it lists that the live type lacks, BEFORE the next live label for an insert ahead of one, and migrate --desired runs each through the same checks, then re-plans to confirm nothing is left. Labels must be distinct and non-empty
CREATE TYPE ... AS ENUM ✅ native, as-is Yes A new type is used by no table, so creating it locks, scans, and rewrites nothing that sessions read or write. migrate resolves the creation schema, checks USAGE and CREATE on it (else insufficient-privileges), and proves the name free: a standalone type or a table's row type at that name is a create-collision refusal, and an autogenerated array type is not, since CREATE TYPE renames it out of the way. The statement runs as one bounded attempt under the brief budgets with lock-timeout retry, with search_path pinned to that schema and under the create owner when one is configured, and confirms before the commit that this transaction created exactly that enum with the declared labels in order and the expected owner (else the permanent enum-type-create-mismatch code, nothing created). A name another session takes after the check is a create-collision refusal. --force, --allow-destructive, and the copy-and-swap acknowledgements do not apply. A desired enum type file for a type the schema lacks plans one CREATE TYPE ... AS ENUM (kind create-enum-type) with the file's labels, and migrate --desired runs it through the same checks, then re-plans to confirm nothing is left. A table that uses a type the same change creates plans when the caller lists that type in NewEnumTypes (diffplan.Request): the scratch build and the add-column probes create it first, in a schema the transaction rolls back, so the column binds to it as it will once the type exists. The caller runs the type's create before the table's statements, and a listed name the schema already holds, as a type or a table's row type, is refused before anything is built. diff and migrate --desired take one file at a time, so run the type's file before the table file that uses it. A CREATE TYPE ... AS ENUM inside a desired table file is refused as catalog work that belongs in its own file
Enum value rename / removal 🟡 copy-and-swap Yes PostgreSQL has no DROP VALUE; this is a type swap + table rewrite, planned on copy-and-swap. Today the imperative door refuses ALTER TYPE ... RENAME VALUE as unsupported-statement, since the only ALTER TYPE form it takes is ADD VALUE, and DROP VALUE does not parse. A desired enum type file that no longer lists a live label is refused as unsupported-statement for the direct operator, who renames the label with ALTER TYPE ... RENAME VALUE or keeps it in the file; one that lists the live labels in another order is refused by design, since PostgreSQL cannot move a label
Domain and other type creation, and type drop ⚪ — No — owner tooling (psql, shipped with the code change) Bootstrap/catalog work with no concurrent-access problem; owner tooling applies it in the same change that ships the code. Both doors refuse creating a type other than an enum, and dropping any type, as catalog work owned by the direct operator: migrate refuses the statement, and diff and migrate --desired refuse a desired file that declares a domain or other non-enum type before anything is planned. An enum type is created natively (see the CREATE TYPE ... AS ENUM row)
Views, materialized views (create and replace) ⚪ — No — owner tooling Transactional catalog work, but CREATE OR REPLACE VIEW takes a brief ACCESS EXCLUSIVE on the view and queues behind in-flight readers — run it under a lock_timeout
REFRESH MATERIALIZED VIEW 🔵 — No — data jobs / owner tooling A data operation, not catalog work: the plain form holds ACCESS EXCLUSIVE on the matview for the whole rebuild (CONCURRENTLY needs a unique index and trades the lock for churn). Scheduling refreshes belongs to data jobs
PL/pgSQL function bodies (CREATE OR REPLACE FUNCTION) ⚪ — No — owner tooling Transactional catalog work that takes no lock on any relation; nothing for an online engine to add. No peer online executor owns it either
Triggers (CREATE TRIGGER) ⚪ — No — owner tooling Catalog work — no scan, no rewrite — but it takes a brief SHARE ROW EXCLUSIVE on the table, queues behind long-running queries, and blocks writers while it waits — run it under a lock_timeout
Extensions (CREATE EXTENSION) ⚪ — No — owner tooling Same: catalog bootstrap, owner tooling
Grants, roles, and imperative policy DDL 🔵 — No — provisioning / IaC Access control changes remain with provisioning. Export includes RLS when present; explicit RLS declarations support comparison and review-only deltas with advisory access warnings. Plain table files leave access control separately managed. The separate atomic RLS Go executor supports RLS-only changes on existing supported tables; migrate --desired uses this executor; imperative policy statements remain refused. See the workflow and roadmap. See engine-role.md for the engine's own role
Complete table-local RLS definition (Go API and migrate --desired) ✅ native, safer sequence Yes The atomic RLS executor locks an existing supported table, refuses structural changes, replaces policies/settings, and verifies convergence before committing. Go callers can preview the ordered SQL and require it to match under lock before execution. This is a SQL review contract, not a catalog snapshot. Lock waits and the whole transaction are bounded. When the table does not exist, migrate --desired creates it with its RLS in one transaction, so it is never visible without its policies. When the live RLS already matches the file and only the table definition differs, migrate --desired (Go: migrate.RunDesiredWithRowSecurity) runs the ordinary table plan, never writes a policy, and reports executed only when a fresh plan, RLS included, is empty. Available through migrate --desired without RLS-specific flags; diff remains a review-only surface for existing tables and previews the create for a missing one
Standalone sequences ⚪ — No — owner tooling Transactional catalog work on an object with no readers-and-writers problem
Publications, subscriptions 🔵 — No — replication provisioning / IaC Replication provisioning, not table shape (ALTER PUBLICATION ... ADD TABLE also takes SHARE UPDATE EXCLUSIVE on the table)

Data and whole-table operations

Operation Status Engine path Online-safety problem? Behavior and why
DROP TABLE ⚪ — No — owner tooling, through a reviewed process Discards the table and its data in one brief ACCESS EXCLUSIVE step: there is nothing online for an engine to make safer, only an irreversible decision an operator must own. Both front doors refuse it: the imperative door as an unsupported statement kind, and the declarative diff is single-table scoped, so a live table with no desired file is not in its view. A whole-schema owner that has reviewed the drop runs it through the Go API, executor.ExecuteDropTable, which drops the table only if it still has the reviewed definition; see Deliberately operator-owned
Data backfills, UPDATE/DELETE batches, DML of any kind 🔵 — No — data-change runners, application batch jobs pg-sprite changes table shape, never table contents. Versioned-script runners and application jobs own data changes
Column-transform expressions during a copy-and-swap rewrite ✅ preview copy-and-swap Yes The one principled exception: when a rewrite is already copying every row, deriving the retyped column's value by expression is part of the shape change, not a data job. ALTER COLUMN TYPE … USING expr runs the expression per row during the copy and through the stream
Online table rebuild with no shape change (bloat reclamation) 🟡 copy-and-swap Yes A copy-and-swap with an identical target shape — the pg_repack use case with checksum-gated cutover and crash-resume. Planned; the planner has no statement form that requests it yet
Whole-schema convergence (apply a directory of desired files, dependency-ordered) 🔵 — No — convergence planners (pg-schema-diff, pgschema, pgdelta) Convergence planning across objects is a planner's job; pg-sprite stays the execution engine for the table-shape subset
Versioned schema-change-file workflow (Flyway-style ordered scripts) 🔵 — No — versioned-script runners (Flyway-style) Declarative-only by design; see vision.md
Expand/contract dual-schema versions (pgroll/reshape style) 🔵 — No — pgroll/reshape own this model Rejected: application invisibility is a core invariant; see vision.md

Peers share these limits — for different reasons

Every tool in this space draws a line around what it models. What differs is why the line sits where it does, and what happens when you cross it:

  • Imperative online executors (pg-osc, pg_repack; gh-ost and Spirit in MySQL) never create enums, extensions, or triggers because the question never arises: they execute exactly the ALTER handed to them. The scope limit is implicit and undocumented — you discover it when raw SQL errors out mid-change.
  • pgroll models a JSON operation vocabulary, and everything outside it goes through a raw-SQL passthrough: executed verbatim, with none of pgroll's safety machinery applied. That is passthrough, not support — the tool runs what it cannot analyze.
  • Declarative planners (pg-schema-diff, pgschema, pgdelta) model far more breadth — enums, views, functions — because their product is a DDL artifact, not an execution. Breadth is cheap when you don't own what happens under concurrent load.

pg-sprite's position: model narrowly, execute what the model covers with provable online safety, and make every boundary a typed refusal, with this page stating its tier — planned (with a real plan) or out of scope (with the tool class that owns the job). The scope limit is explicit, documented on this page, and machine-checkable via exit codes.

Why typed refusal, not passthrough

The obvious middle ground — refuse, then offer --apply-anyway — is deliberately not implemented. The trade was weighed, not overlooked:

What passthrough would buy. One pipeline and one audit trail for every change; no side-channel psql sessions; lower adoption friction when users hit a boundary. pgroll demonstrates the demand is real.

Why it loses. The exit-code contract — 0 means this ran through an online-safe path — is the product. A passthrough mode means pg-sprite executed something it cannot vouch for, and every incident that follows lands on the tool's reputation, not the flag. It also breaks the ownership model that crash recovery depends on: the executor can reason about an interrupted change (see invalid-index-recovery.md) only because it knows exactly what it runs; arbitrary SQL has no resume semantics. And refusals are the forcing function that gets real capabilities built — a passthrough is where demand signals go to die.

What you get instead. Every refusal names the classification, the reason, and — where one exists — the exact safer sequence or the statement an operator can run deliberately, outside the engine, in a maintenance window. The operator stays in control; the engine stays honest. --force never bypasses a policy refusal.

A constrained variant exists: migrate --accept-blocking SCHEMA.TABLE, an explicit, dedicated acceptance (distinct from --force, and not combinable with it) executes an otherwise-refused change through the engine's own bounded lock_timeout / statement_timeout session ("unsafe DDL under a bounded lock budget", which raw psql does not give you), with the refusal analysis still produced before execution and the verdict unmistakably marked as executed without an online-safety guarantee (outcome: executed-without-online-safety, blocking_passthrough: true, exit 3 — never 0). The value must name the table whose lock you accept — the owning table of the index — resolved from the catalog, and --statement-timeout must be spelled on the same command line. Only changes the engine understands but cannot run safely are eligible: today a single-relation plain DROP INDEX (never CASCADE, which also drops dependent objects such as a foreign key on another table), REINDEX INDEX, or REINDEX TABLE. A DROP INDEX also discards the index, so it needs --allow-destructive naming the same table; without it the drop is refused with destructive-change before anything runs. Refusals for unrecognized SQL never are, and the refused statement's blocking_passthrough_eligible field on the plan report says whether a refusal qualifies. An exhausted lock budget is still a refusal (exit 2, nothing ran); a statement cancelled by its budget is a failure (exit 1). The design is lock-budgeted-passthrough.md.

Deliberately operator-owned

Three related jobs stay with humans on purpose:

  • Dropping a table nobody declares any more. The declarative diff is single-table scoped and whole-schema convergence is a planner's job (see the 🔵 row in the matrix), so pg-sprite has no view of which tables a schema should contain — only of each table's shape. Under a declarative model the only convergence for a live table with no desired file is DROP TABLE, and pg-sprite never plans one. Whoever owns the whole schema — an orchestrator, or an operator running diff per file — therefore owns the set of tables: decide how far the declared files are authoritative, enumerate the live tables, and treat each undeclared one as a destructive divergence to resolve rather than as up to date. Declare it (pull writes the desired file) or drop it through a reviewed process; whether the owner blocks on it or quarantines it first (ALTER TABLE … SET SCHEMA / RENAME TO) is the owner's policy, not pg-sprite's. A schema being onboarded is entirely undeclared tables, so declare the existing tables first (pull writes one desired file per table), or scope the owner's authority to the schemas it manages. schemadiff.ListManagedTables implements the catalog query used by pull and is available to owners that need the same enumeration. It lists the tables a schema directory is expected to account for, not the files pull can write: partitions are represented through their parent's PARTITION BY and extension members belong to their extension, so neither is listed, while a listed table whose shape export refuses (the declarative model's limits, under The two front doors) is still undeclared and still the owner's to resolve; pull reports each refusal by table. The exclusions matter, because every false positive blocks a table nobody touched:

    SELECT c.relname
    FROM pg_catalog.pg_class c
    JOIN pg_catalog.pg_namespace n
      ON n.oid OPERATOR(pg_catalog.=) c.relnamespace
    WHERE n.nspname OPERATOR(pg_catalog.=) 'app'
      AND (c.relkind OPERATOR(pg_catalog.=) 'r'
           OR c.relkind OPERATOR(pg_catalog.=) 'p')    -- ordinary and partitioned tables only
      AND NOT c.relispartition                         -- partitions belong to their parent
      AND NOT EXISTS (SELECT 1 FROM pg_catalog.pg_depend d
                      WHERE d.classid OPERATOR(pg_catalog.=)
                              'pg_catalog.pg_class'::pg_catalog.regclass
                        AND d.objid OPERATOR(pg_catalog.=) c.oid
                        AND d.deptype OPERATOR(pg_catalog.=) 'e') -- extension-owned tables have no file to write
    ORDER BY c.relname;

    Qualify every relation, operator, and type with pg_catalog.: under a user-first search_path, an unqualified relation or = joins nothing and returns an empty — passing — result, and an unqualified regclass cast stops matching the extension dependency and lists extension members as undeclared. Views, materialized views, foreign tables, and sequences are outside the model and are not undeclared tables. The planner's scratch objects live in a schema of their own (pgsprite_scratch_<random>) inside a transaction that is always rolled back, so a listing scoped to the owner's schema never sees them. schemadiff.ScratchSchemaPrefix exports the name's prefix, so a DDL guard on the target, such as an event trigger, can exempt the scratch build's CREATE SCHEMA and the DDL inside it. The prefix names the scratch build's objects but does not authenticate them: any role that can create a schema can pick such a name. Scope the exemption to the role pg-sprite connects as, for example by checking session_user. The copy-and-swap route's own tables do live in the owner's schema — a stopped run's _pgsprite_<hash>_new shadow and a --keep-old source retained as _pgsprite_<hash>_old — so ListManagedTables leaves out of its result every row whose name schemadiff.IsEngineRelationName matches; an owner running the query by hand applies the same check, or it is asked to declare or drop a rollback copy.

    Once a reviewer has accepted a drop, the owner runs it with executor.ExecuteDropTable. At plan time, record the table's definition with schemadiff.DroppedTableDefinition on the model schemadiff.Introspect returns. At run time the executor locks the table, reads it again, and drops it without CASCADE in one transaction. It refuses, dropping nothing:

    Code When
    dropped-object-drift The table no longer has the reviewed definition, or the name is now a view
    dropped-object-has-descendants The table is partitioned or has inheritance children
    dropped-table-has-parent The table is a partition or an inheritance child
    dropped-table-has-dependents A view, another table's foreign key, or another object depends on it
    table-not-found The table is already gone

    The drop is not undone: back up the rows first if they may be needed again.

  • Deciding to recover an invalid index. A failed CREATE INDEX CONCURRENTLY leaves an invalid index; an in-flight healthy build looks identical. The build never drops an index itself — PostgreSQL drops by name, not identity, so a drop on the way in could destroy another actor's build. Recovery is a separate, explicit call (executor.RebuildAbandonedIndex, or executor.DropAbandonedIndex when the caller must not rebuild; both library-only) that removes an entry only after proving it abandoned under the table lock and by catalog identity (LK-5), and refuses an in-flight build, another table's entry, or an entry the server will not drop concurrently — a partitioned table's index, an index partition, or a constraint's index is never debris and is never touched. The typed ownership states, which of them the recovery handles, and what the rest license a human to do is invalid-index-recovery.md.

  • Index maintenance (REINDEX automation, bloat-driven rebuild scheduling). The engine runs REINDEX only as an accepted blocking statement under --accept-blocking (see matrix) — run REINDEX ... CONCURRENTLY directly; deciding when an index needs rebuilding is monitoring-and-operations territory. Automating it is considered but on hold for the same ownership reasons as above.


Keeping this page honest: any change that adds, lifts, or re-tiers a refusal must update this matrix in the same PR, and each release's notes link here. A support question this page cannot answer is a bug in this page.