mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-15 14:35:54 +00:00
Fixing person_content_combined migration uniques. (#5324)
This commit is contained in:
parent
9c1347c7a0
commit
b901714d71
1 changed files with 6 additions and 2 deletions
|
@ -33,8 +33,12 @@ CREATE TABLE person_saved_combined (
|
|||
id serial PRIMARY KEY,
|
||||
saved timestamptz NOT NULL,
|
||||
person_id int NOT NULL REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
post_id int UNIQUE REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
comment_id int UNIQUE REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
comment_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
-- Unique constraints are different here, check for person AND item.
|
||||
-- Otherwise you won't be able to add multiple posts
|
||||
UNIQUE (person_id, post_id),
|
||||
UNIQUE (person_id, comment_id),
|
||||
-- Make sure only one of the columns is not null
|
||||
CHECK (num_nonnulls (post_id, comment_id) = 1)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue