Limit likes to one per-user per-building (db constraint)

This commit is contained in:
Tom Russell 2018-12-11 17:17:41 +00:00
parent 9450f29449
commit da64c153fc
3 changed files with 4 additions and 3 deletions

View File

@ -84,6 +84,3 @@ CREATE TABLE IF NOT EXISTS building_user_likes (
); );
CREATE INDEX building_likes_idx ON building_user_likes ( building_id ); CREATE INDEX building_likes_idx ON building_user_likes ( building_id );
CREATE INDEX user_likes_idx ON building_user_likes ( user_id ); CREATE INDEX user_likes_idx ON building_user_likes ( user_id );
-- One like per-building, per-user
-- ALTER TABLE building_user_likes ADD CONSTRAINT building_like_once UNIQUE (building_id, user_id);

View File

@ -0,0 +1,2 @@
-- Don't limit likes
ALTER TABLE building_user_likes DROP CONSTRAINT building_like_once;

View File

@ -0,0 +1,2 @@
-- One like per-building, per-user
ALTER TABLE building_user_likes ADD CONSTRAINT building_like_once UNIQUE (building_id, user_id);