From da64c153fcbbaa68b3e724f4462fdf2f1fe1288c Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Tue, 11 Dec 2018 17:17:41 +0000 Subject: [PATCH] Limit likes to one per-user per-building (db constraint) --- migrations/004.location-date-size-like.up.sql | 3 --- migrations/005.limit-likes.down.sql | 2 ++ migrations/005.limit-likes.up.sql | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 migrations/005.limit-likes.down.sql create mode 100644 migrations/005.limit-likes.up.sql diff --git a/migrations/004.location-date-size-like.up.sql b/migrations/004.location-date-size-like.up.sql index 9e41aad1..391e6275 100644 --- a/migrations/004.location-date-size-like.up.sql +++ b/migrations/004.location-date-size-like.up.sql @@ -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 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); diff --git a/migrations/005.limit-likes.down.sql b/migrations/005.limit-likes.down.sql new file mode 100644 index 00000000..96a4261e --- /dev/null +++ b/migrations/005.limit-likes.down.sql @@ -0,0 +1,2 @@ +-- Don't limit likes +ALTER TABLE building_user_likes DROP CONSTRAINT building_like_once; diff --git a/migrations/005.limit-likes.up.sql b/migrations/005.limit-likes.up.sql new file mode 100644 index 00000000..3581b2f2 --- /dev/null +++ b/migrations/005.limit-likes.up.sql @@ -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);