Reproduction
Source schema:
CREATE TABLE parent (
id integer,
payload integer,
PRIMARY KEY (id) INCLUDE (payload)
);
CREATE TABLE child (
parent_id integer REFERENCES parent (id)
);
Target schema changes only parent.payload from integer to bigint.
Actual
The generated plan contains:
ALTER TABLE "parent" ALTER COLUMN "payload" SET DATA TYPE bigint USING "payload"::bigint;
It does not drop/recreate the dependent foreign key or the primary key/index. PostgreSQL then fails because changing an included index column requires rebuilding the primary-key constraint/index:
ERROR: cannot drop constraint parent_pkey on table parent because other objects depend on it
DETAIL: constraint child_parent_id_fkey on table child depends on index parent_pkey
The plan emitted only the access-exclusive-lock hazard for the ALTER COLUMN TYPE; it did not warn that the plan is non-executable due to the dependency.
Expected
Generate an executable migration: drop the child FK, rebuild the PK/index with payload bigint, then recreate the FK (with safe ordering), or detect this unsupported dependency and emit a blocking hazard instead of a plan that PostgreSQL cannot execute.
Version
pg-schema-diff version reports version=(devel). The CLI was built from the integration/open-pr-stack branch of dilame/pg-schema-diff (a fork of this repository). The exact build commit was not embedded in the binary.
Reproduction
Source schema:
Target schema changes only
parent.payloadfromintegertobigint.Actual
The generated plan contains:
It does not drop/recreate the dependent foreign key or the primary key/index. PostgreSQL then fails because changing an included index column requires rebuilding the primary-key constraint/index:
The plan emitted only the access-exclusive-lock hazard for the
ALTER COLUMN TYPE; it did not warn that the plan is non-executable due to the dependency.Expected
Generate an executable migration: drop the child FK, rebuild the PK/index with
payload bigint, then recreate the FK (with safe ordering), or detect this unsupported dependency and emit a blocking hazard instead of a plan that PostgreSQL cannot execute.Version
pg-schema-diff versionreportsversion=(devel). The CLI was built from theintegration/open-pr-stackbranch ofdilame/pg-schema-diff(a fork of this repository). The exact build commit was not embedded in the binary.