Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/diff/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ func constraintsEqual(old, new *ir.Constraint) bool {
if old.CheckClause != new.CheckClause {
return false
}
if old.NoInherit != new.NoInherit {
// NoInherit (connoinherit) is only meaningful for CHECK constraints where
// it controls the NO INHERIT modifier. For PK/UNIQUE/FK/EXCLUDE constraints,
// PostgreSQL sets connoinherit inconsistently (e.g. true for a standalone
// constraint vs false for one created via PARTITION OF), so comparing it
// would cause false diffs on partition children (#495).
if old.Type == ir.ConstraintTypeCheck && old.NoInherit != new.NoInherit {
return false
}
if old.ExclusionDefinition != new.ExclusionDefinition {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE public.p (
band_id integer NOT NULL,
geom_id integer NOT NULL,
CONSTRAINT p_band_id_geom_id_key UNIQUE (band_id, geom_id)
) PARTITION BY LIST (band_id);

CREATE TABLE public.p_12 PARTITION OF public.p FOR VALUES IN (12);
CREATE TABLE public.p_13 PARTITION OF public.p FOR VALUES IN (13);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- This represents what the target database looks like after pgschema apply:
-- partition children created as standalone tables with explicit constraints,
-- then attached to the parent table.
CREATE TABLE public.p (
band_id integer NOT NULL,
geom_id integer NOT NULL,
CONSTRAINT p_band_id_geom_id_key UNIQUE (band_id, geom_id)
) PARTITION BY LIST (band_id);

CREATE TABLE public.p_12 (
band_id integer NOT NULL,
geom_id integer NOT NULL,
CONSTRAINT p_12_band_id_geom_id_key UNIQUE (band_id, geom_id)
);
ALTER TABLE public.p ATTACH PARTITION public.p_12 FOR VALUES IN (12);

CREATE TABLE public.p_13 (
band_id integer NOT NULL,
geom_id integer NOT NULL,
CONSTRAINT p_13_band_id_geom_id_key UNIQUE (band_id, geom_id)
);
ALTER TABLE public.p ATTACH PARTITION public.p_13 FOR VALUES IN (13);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "1.0.0",
"pgschema_version": "1.11.1",
"created_at": "1970-01-01T00:00:00Z",
"source_fingerprint": {
"hash": "b52a7d3e192793cd8af86dbf6b990056fa88b14303a29a10bb55048423a811c0"
},
"groups": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No changes detected.