What happened
DataProviderMigrate (postgres, additive phase) over a declarative schema where an existing table gains one new column that carries a checkConstraint:
- name: workspace_size
type: Text
checkConstraint: "workspace_size IS NULL OR workspace_size IN ('small','medium','large')"
Plan and outcome:
Phase: all — applying 2 of 2 operation(s):
AddColumnOperation
AddCheckConstraintOperation
Error: migration apply failed: 42710: constraint "agent_configs_workspace_size_chk" for relation "agent_configs" already exists
The whole apply rolls back, so the column never lands: information_schema.columns and pg_constraint both show nothing afterwards, and every re-run fails the same way.
Diagnosis
AddColumnOperation already emits the column-level CHECK (named <table>_<column>_chk), and the planner also schedules a separate AddCheckConstraintOperation for the same declaration with the same name. On a fresh CREATE TABLE this does not happen, which is why the same YAML pattern works for columns declared at table-creation time.
Expected
One of:
- the planner emits only
AddColumnOperation (with the inline check) when the column is new, or
AddColumnOperation emits the bare column and leaves the check to AddCheckConstraintOperation.
Environment
- Postgres 17 (Supabase)
- Provider: postgres
- Consumer: Nimblesite/NimblesiteAgenticPlatform
migrations/schema.yaml, table agent_configs
What happened
DataProviderMigrate(postgres, additive phase) over a declarative schema where an existing table gains one new column that carries acheckConstraint:Plan and outcome:
The whole apply rolls back, so the column never lands:
information_schema.columnsandpg_constraintboth show nothing afterwards, and every re-run fails the same way.Diagnosis
AddColumnOperationalready emits the column-levelCHECK(named<table>_<column>_chk), and the planner also schedules a separateAddCheckConstraintOperationfor the same declaration with the same name. On a freshCREATE TABLEthis does not happen, which is why the same YAML pattern works for columns declared at table-creation time.Expected
One of:
AddColumnOperation(with the inline check) when the column is new, orAddColumnOperationemits the bare column and leaves the check toAddCheckConstraintOperation.Environment
migrations/schema.yaml, tableagent_configs