pgschema version: 1.9.0
Description
A schema with quoted mixed-case column names and circular foreign key dependencies cannot be round-tripped through pgschema dump + pgschema plan. The dump produces a desired state file that pgschema plan refuses to load.
Steps to reproduce
# 0. Start PostgreSQL
docker run --rm -d --name pg15 -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres:15
# 1. Create databases and load the schema
psql -h localhost -U postgres -c "CREATE DATABASE plandb"
psql -h localhost -U postgres -c "CREATE DATABASE targetdb"
psql -h localhost -U postgres -d targetdb -c "
CREATE TABLE aaa (
\"aId\" bigint NOT NULL,
\"bId\" bigint,
CONSTRAINT aaa_pkey PRIMARY KEY (\"aId\")
);
CREATE TABLE bbb (
\"bId\" bigint NOT NULL,
\"aId\" bigint,
CONSTRAINT bbb_pkey PRIMARY KEY (\"bId\")
);
ALTER TABLE aaa ADD CONSTRAINT aaa_fk FOREIGN KEY (\"bId\") REFERENCES bbb (\"bId\") DEFERRABLE;
ALTER TABLE bbb ADD CONSTRAINT bbb_fk FOREIGN KEY (\"aId\") REFERENCES aaa (\"aId\") DEFERRABLE;
"
# 2. Dump the schema
pgschema dump \
--host localhost --port 5432 --user postgres \
--db targetdb --sslmode disable \
> desired.sql
# 3. Plan against the same database — expects zero drift
pgschema plan \
--host localhost --port 5432 --user postgres \
--db targetdb --sslmode disable \
--plan-host localhost --plan-port 5432 \
--plan-user postgres --plan-db plandb --plan-sslmode disable \
--file desired.sql
Expected result
Actual result
Error: failed to apply desired state: failed to apply schema SQL to temporary schema
pgschema_tmp_...: ERROR: column "bid" referenced in foreign key constraint does not exist (SQLSTATE 42703)
pgschema version: 1.9.0
Description
A schema with quoted mixed-case column names and circular foreign key dependencies cannot be round-tripped through
pgschema dump+pgschema plan. The dump produces a desired state file thatpgschema planrefuses to load.Steps to reproduce
Expected result
Actual result