Я использую Postgres 12:
CREATE TABLE w_table (
id INT PRIMARY KEY
);
CREATE TABLE l_table (
id INT GENERATED ALWAYS AS identity,
w_id int NOT NULL REFERENCES w_table(id),
PRIMARY KEY (w_id, id),
UNIQUE (w_id, id)
)PARTITION BY LIST (w_id);
CREATE TABLE t_table (
id INT GENERATED ALWAYS AS IDENTITY,
w_id INT REFERENCES w_table(id) NOT NULL,
l_id INT REFERENCES l_table(id) NOT NULL,
PRIMARY KEY (w_id,id),
UNIQUE (w_id,id)
)PARTITION BY LIST (w_id);
И получаю:
ERROR: there is no unique constraint matching given keys for referenced table "l_table"
Не могу понять, что я делаю не так.
Спасибо!