retrofit
0.14.0
retrofit.sh

Operators

Every schema modification operator, by name, with its category and a one-line summary. The last five columns name the commands that work with operators and say, for each, whether it handles the operator in this version: available or not available. For an operator’s full reference, run retrofit op info <operator>.

OperatorCategorySummaryop addimportdriftsnapshotmigrate
AddCheckconstraintDeclare a CHECK constraint enforcing a row-level predicate.availableavailableavailableavailableavailable
AddColumncolumnAdd a column to an existing table.availableavailableavailableavailableavailable
AddEnumValuetypeAppend a new value to an existing enum type.availableavailablenot availableavailableavailable
AddExcludeconstraintDeclare an EXCLUDE constraint: no two rows’ keys may all compare true under the listed operators.availableavailableavailableavailableavailable
AddForeignKeyconstraintDeclare a foreign-key constraint to referenced_columns in referenced_table.availableavailableavailableavailableavailable
AddIdentitycolumnPromote an existing column to GENERATED { BY DEFAULT | ALWAYS } AS IDENTITY. PG mints a fresh backing sequence starting at identity_start (else PostgreSQL’s default: its minimum value, or its maximum when it counts down) and does NOT advance it past the column’s existing values, so migrate emits a realignment statement after the ALTER; without it the migration applies cleanly and the next insert collides.availableavailableavailableavailableavailable
AddNotNullcolumnSet the column’s NOT NULL bit on the column vertex.availableavailableavailableavailableavailable
AddPrimaryKeyconstraintDeclare a primary-key constraint over the listed columns.availableavailableavailableavailableavailable
AddUniqueconstraintDeclare a UNIQUE constraint over the listed columns.availableavailableavailableavailableavailable
AttachPartitiontableSubordinate a free-standing table as a partition of a partitioned parent (its columns end into the parent’s).availableavailableavailableavailableavailable
CastColumncolumnChange a column’s SQL type in place.availableavailableavailableavailableavailable
ChangePrimaryKeyconstraintReplace a table’s primary key with a new column set; preserves the cascade genealogy across the PK and every dependent FK constraint via N+1 EdgeKindCrossElement edges minted at replay.availableavailableavailableavailableavailable
CopyColumncolumnDuplicate a column on the same parent table: mint a fresh column whose initial values are seeded from an existing source column. Type/default/nullability are inherited from the source unless overridden. The new column is born unconstrained; re-attach PK/FK/UNIQUE/CHECK/index against the new ElementID via separate ops.availablenot availablenot availableavailableavailable
CopyTabletableCreate a new table that is an independent copy of source.availablenot availableavailableavailableavailable
CreateExtensionrootInstall a PostgreSQL extension at the cluster (database) level.availableavailableavailableavailableavailable
CreateFunctionfunctionCreate a new function inside the target schema. Identity is (schema, composite-name).availableavailableavailableavailableavailable
CreateIndexindexCreate a physical index over the listed columns.availableavailableavailableavailableavailable
CreateMaterializedViewviewCreate a new materialized view inside the target schema.availableavailableavailableavailableavailable
CreatePartitiontableCreate a partition under a partitioned parent (columns inherited).availableavailableavailableavailableavailable
CreatePolicypolicyCreate a row-level-security policy on a table. Identity is (table, name).availableavailableavailableavailableavailable
CreateSchemarootMint the root schema element.availableavailablenot availableavailableavailable
CreateTabletableCreate a new table inside the target schema.availableavailableavailableavailableavailable
CreateTriggertriggerCreate a trigger on a table or view. Identity is (table, name).availableavailableavailableavailableavailable
CreateTypetypeCreate a user-defined type (enum or composite) in the target schema.availableavailablenot availableavailableavailable
CreateViewviewCreate a new view inside the target schema.availableavailableavailableavailableavailable
DeclareReversallogDeclare how a sealed RunRawScript is undone: a reverse_body, a no-op or forward-only with its reason, or (with no arm) a withdrawal of the declaration it supersedes.availablenot availablenot availablenot availablenot available
DepartitionTabletableFlatten a partitioned parent back to a plain heap, tombstoning its partition-children.availablenot availableavailableavailableavailable
DetachPartitiontableDetach a partition into a free-standing table (rows kept).availableavailableavailableavailableavailable
DisableTriggertriggerDisable an enabled trigger.availableavailableavailableavailableavailable
DropCheckconstraintConsume the target CHECK constraint.availableavailableavailableavailableavailable
DropColumncolumnConsume the target column element.availableavailableavailableavailableavailable
DropDefaultcolumnClear a column’s DEFAULT expression. Replay rejects against a column with no current default.availableavailableavailableavailableavailable
DropExcludeconstraintConsume the target EXCLUDE constraint.availableavailableavailableavailableavailable
DropExtensionrootDrop a PostgreSQL extension.availableavailableavailableavailableavailable
DropForeignKeyconstraintConsume the target foreign-key constraint.availableavailableavailableavailableavailable
DropFunctionfunctionConsume the target function element.availableavailableavailableavailableavailable
DropGeneratedExpressioncolumnClear a stored generated column’s expression, converting it to a base column. Replay rejects against a column with no current generated expression or a virtual generated column.availableavailableavailableavailableavailable
DropIdentitycolumnRemove the identity property from a column. The implicit NOT NULL is preserved; use DropNotNull to clear it.availableavailableavailableavailableavailable
DropIndexindexConsume the target index element.availableavailableavailableavailableavailable
DropMaterializedViewviewConsume the target materialized view element.availableavailableavailableavailableavailable
DropNotNullcolumnClear the column-vertex NOT NULL bit.availableavailableavailableavailableavailable
DropPolicypolicyConsume the target policy element.availableavailableavailableavailableavailable
DropPrimaryKeyconstraintConsume the target primary-key constraint.availableavailableavailableavailableavailable
DropTabletableConsume the target table element.availableavailableavailableavailableavailable
DropTriggertriggerConsume the target trigger element.availableavailableavailableavailableavailable
DropTypetypeConsume a user-defined type element. Refused at op-add when any live column binds to it.availableavailableavailableavailableavailable
DropUniqueconstraintConsume the target UNIQUE constraint.availableavailableavailableavailableavailable
DropViewviewConsume the target view element.availableavailableavailableavailableavailable
EnableTriggertriggerEnable a disabled trigger.availableavailableavailableavailableavailable
ExtractTabletableExtract columns into new related tables (column-axis split; normalizes a wide table). A child copies the source’s primary key, keeping every row’s data, or designates key columns it shares with the source (the lookup: one child row per distinct key, the source rows with a NULL key component losing their moved values). With a remainder the source survives in place holding the unassigned columns; with every live column assigned the source is consumed.availableavailableavailableavailableavailable
InlineTabletableInline one or more child tables back into a live table along their primary keys (keyed column fold, folding an extracted child back into its survivor). The survivor keeps its identity; each inlined source’s columns reparent onto it and the source is consumed. A survivor row with no inlined row is padded with NULL or the column’s default.availablenot availablenot availableavailableavailable
JoinTabletableJoin two tables’ columns into one (denormalize; column-axis join along a recorded key pairing). Identity-preserving at the column level: each source column is reparented to the new target with its existing ElementID. Rejects on column-name collision across sources (resolve via prior RenameColumn). The key_pairs are the ordered column pairs the sources are joined on (each side’s columns a PRIMARY KEY or UNIQUE of that source); kind picks the JOIN flavor (inner/left/right/full).availablenot availableavailableavailableavailable
MergeTabletableMove the rows of several tables into a live table of their shape, one predicate recorded per source (row-axis merge).availablenot availableavailableavailableavailable
MoveColumntableMove a column to another table along a recorded key pairing, keeping its identity and carrying each value to its partner row. The column’s ElementID survives the move; only the parent table changes. Renames are a separate operator.availableavailableavailableavailableavailable
PartitionTabletableConvert a plain table to a partitioned parent in place, minting N partitions atomically.availablenot availableavailableavailableavailable
RenameColumncolumnRename the target column inside its containing table.availableavailableavailableavailableavailable
RenameConstraintconstraintRename a constraint without dropping it. Element identity is preserved; the first rename of a PG-default-named constraint assigns the first explicit name.availableavailableavailableavailableavailable
RenameEnumValuetypeRename an existing enum value in place.availableavailablenot availableavailableavailable
RenameFunctionfunctionRename the target function to a new name in its schema.availableavailableavailableavailableavailable
RenameIndexindexRename the target index inside its containing table.availableavailableavailableavailableavailable
RenameMaterializedViewviewRename the target materialized view to a new name in its schema.availableavailableavailableavailableavailable
RenameOwnedSequencecolumnRename the sequence a column owns (its serial or identity sequence) without touching the column.availableavailableavailableavailableavailable
RenamePolicypolicyRename a policy within its owning table.availableavailableavailableavailableavailable
RenameTabletableRename the target table to a new name in its schema.availableavailableavailableavailableavailable
RenameTriggertriggerRename the target trigger.availableavailableavailableavailableavailable
RenameTypetypeRename a user-defined type. Element identity (typeRef) is preserved across the rename.availableavailablenot availableavailableavailable
RenameViewviewRename the target view to a new name in its schema.availableavailableavailableavailableavailable
ReplaceFunctionfunctionReplace a function’s body and mutable attributes. Signature is identity-fixed by on= and cannot change.availableavailableavailableavailableavailable
ReplaceMaterializedViewviewReplace the body of an existing materialized view (DROP CASCADE + CREATE realization).availablenot availableavailableavailableavailable
ReplacePolicypolicyReplace a policy’s TO / USING / WITH CHECK. Cannot change permissive or command (those are identity-fixed; use Drop+Create).availableavailableavailableavailableavailable
ReplaceViewviewState the view’s whole new definition: query and column list, same element.availableavailableavailableavailableavailable
RunRawScriptopaqueRun-once raw statement sequence with no catalog identity (a DO $$ … $$; anonymous block). A body or reverse_body whose every name binds is bound to the elements it names: migrate renders each as its element’s name at the script’s position, so a rename before it is followed and a drop before it refuses; dynamic SQL, names as data, or a form the binder does not follow keeps a body opaque, emitted verbatim, with a finding naming the cause. A body whose DO block holds COMMIT or ROLLBACK cannot run inside a transaction block (SQLSTATE 2D000): migrate segments around it under --envelope=own, refuses migrate-tx-incompatible under caller and advises under independent. migrate --down reads its reversal: an optional reverse_body is emitted unchecked, except that one holding COMMIT or ROLLBACK refuses migrate-non-reversible (the down never segments); reverse_noop contributes nothing, reverse_blocked refuses; no structural diff target; drift has no synthesis path. The escape hatch below the Structural/Definitional partition.availableavailablenot availableavailableavailable
SeallogMark a range of prior ops as sealed (immutable, Merkle-digested).availableavailablenot availablenot availableavailable
SetColumnCommentcolumnSet or clear a column comment. Empty text clears.availableavailableavailableavailableavailable
SetConstraintCommentconstraintSet or clear a constraint comment. Empty text clears (mirrors PG COMMENT ON CONSTRAINT … ON … IS NULL).availableavailableavailableavailableavailable
SetConstraintDeferrableconstraintToggle the DEFERRABLE bit on an FK constraint (PG’s ALTER CONSTRAINT is FK-only; UNIQUE / PK can be born deferrable via AddUnique / AddPrimaryKey but not toggled post-birth). Replay rejects no-op writes.availableavailableavailableavailableavailable
SetConstraintEnforcedconstraintToggle the ENFORCED bit on a foreign-key (FK) constraint (PostgreSQL alters the enforceability of foreign keys only).not availablenot availablenot availablenot availablenot available
SetConstraintInheritconstraintToggle the NO INHERIT bit on a NOT NULL constraint (PostgreSQL’s per-constraint INHERIT / NO INHERIT applies to NOT NULL only).not availablenot availablenot availablenot availablenot available
SetConstraintInitiallyDeferredconstraintToggle the INITIALLY DEFERRED bit on an FK constraint (PG’s ALTER CONSTRAINT is FK-only; UNIQUE / PK can be born initially-deferred via AddUnique / AddPrimaryKey but not toggled post-birth). Requires the constraint to already be DEFERRABLE; replay rejects no-op writes.availableavailableavailableavailableavailable
SetDefaultcolumnSet or replace a column’s DEFAULT expression. Single-slot semantics; overwrites whatever default is in effect.availableavailableavailableavailableavailable
SetFunctionCommentfunctionSet or clear a function comment. Empty text clears (mirrors PG COMMENT ON FUNCTION … IS NULL).availableavailableavailableavailableavailable
SetIdentityGenerationcolumnSwap an identity column’s generation mode between BY DEFAULT and ALWAYS without dropping the underlying sequence.availableavailableavailableavailableavailable
SetIdentityOptionscolumnChange an identity column’s sequence options (START, INCREMENT, MINVALUE, MAXVALUE, CACHE, CYCLE); an option it does not name keeps its value, and the sequence keeps its position.availableavailableavailableavailableavailable
SetReferenceDatatableDeclare or undeclare the target table as reference data.availablenot availablenot availablenot availablenot available
SetReplicaIdentitytableSet the table’s REPLICA IDENTITY mode. mode=using_index requires index=<index>, a unique, immediate, non-partial, column-only index on this table over NOT NULL columns.availableavailableavailableavailableavailable
SetRowLevelSecuritypolicySet a table’s ROW LEVEL SECURITY enabled/forced facets (absolute {enabled, forced} payload).availableavailableavailableavailableavailable
SetTableCommenttableSet or clear a table comment. Empty text clears (mirrors PG COMMENT ON TABLE … IS NULL).availableavailableavailableavailableavailable
SplitTabletableMove a table’s rows into N new tables of its shape by first-match predicate; the source stays (row-axis split).availablenot availablenot availableavailableavailable
UnjoinTabletableTake a join apart along the keys its sides hold into two new related tables (keyed table unjoin, undoing a join of any kind). Every live column of the source is assigned to exactly one child and the source is consumed; each child keeps its columns’ identities.availablenot availablenot availableavailableavailable
ValidateConstraintconstraintPromote a NOT VALID foreign-key or CHECK constraint to validated.availableavailableavailableavailableavailable
WitnessReferenceDatatableAttest a reference-data record’s bytes at its key (written by retrofit data witness).availablenot availablenot availablenot availablenot available

Before 1.0, any release may change behavior; the release notes list what changed.

Published .