You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
table_child references table_parent with foreign key but table_child is created first and then table_parent
How to repoduce:
Source database:
DROPSCHEMA IF EXISTS schema1 CASCADE;
CREATESCHEMAschema1;
CREATETABLEschema1.b_parent_table (
id BIGSERIALPRIMARY KEY,
name TEXT
);
CREATETABLEschema1.a_child_table (
id BIGSERIALPRIMARY KEY,
name TEXT,
parent_id BIGINTREFERENCESschema1.b_parent_table(id)
);
Target database:
DROPSCHEMA IF EXISTS schema1 CASCADE;
CREATESCHEMAschema1;
Output:
---- pgquarrel 0.7.0-- quarrel between 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1) and 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)--CREATESEQUENCEschema1.a_child_table_id_seq NO MINVALUE NO MAXVALUE;
CREATESEQUENCEschema1.b_parent_table_id_seq NO MINVALUE NO MAXVALUE;
CREATETABLEschema1.a_child_table (
id bigint DEFAULT nextval('schema1.a_child_table_id_seq'::regclass) NOT NULL,
name text,
parent_id bigint
);
ALTERTABLE ONLY schema1.a_child_table
ADD CONSTRAINT a_child_table_pkey PRIMARY KEY (id);
-- HERE b_parent_table TABLE DOES NOT EXIST YETALTERTABLE ONLY schema1.a_child_table
ADD CONSTRAINT a_child_table_parent_id_fkey FOREIGN KEY (parent_id) REFERENCESschema1.b_parent_table(id);
ALTERSEQUENCEschema1.a_child_table_id_seq OWNED BY schema1.a_child_table.id;
CREATETABLEschema1.b_parent_table (
id bigint DEFAULT nextval('schema1.b_parent_table_id_seq'::regclass) NOT NULL,
name text
);
ALTERTABLE ONLY schema1.b_parent_table
ADD CONSTRAINT b_parent_table_pkey PRIMARY KEY (id);
ALTERSEQUENCEschema1.b_parent_table_id_seq OWNED BY schema1.b_parent_table.id;
As you see at the moment of ADD CONSTRAINT a_child_table_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES schema1.b_parent_table(id); the table schema1.b_parent_table(id) does not exist yet
The text was updated successfully, but these errors were encountered:
@hazardlandpgquarrel does not handle dependencies accordingly. It uses a natural order of object classes to build the diff output. There are some issues that refers to this same issue #49#52#68#69. Unfortunately the workaround is to test your script and reorder the commands if necessary. This feature is already in my roadmap.
table_child
referencestable_parent
with foreign key buttable_child
is created first and thentable_parent
How to repoduce:
Source database:
Target database:
Output:
As you see at the moment of
ADD CONSTRAINT a_child_table_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES schema1.b_parent_table(id);
the tableschema1.b_parent_table(id)
does not exist yetThe text was updated successfully, but these errors were encountered: