-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make favorites unique, and add timestamp
- Loading branch information
1 parent
ba7cc98
commit f54c444
Showing
4 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
pkg/database/migrations/postgres/47_favorite_unique.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
DELETE FROM "performer_favorites" PF | ||
WHERE EXISTS ( | ||
SELECT FROM "performer_favorites" | ||
WHERE performer_id = PF.performer_id | ||
AND user_id = PF.user_id | ||
AND ctid < PF.ctid | ||
); | ||
|
||
CREATE UNIQUE INDEX "performer_favorites_unique_idx" ON "performer_favorites" (performer_id, user_id); | ||
|
||
DROP INDEX performer_favorites_idx; | ||
|
||
DELETE FROM "studio_favorites" SF | ||
WHERE EXISTS ( | ||
SELECT FROM "studio_favorites" | ||
WHERE studio_id = SF.studio_id | ||
AND user_id = SF.user_id | ||
AND ctid < SF.ctid | ||
); | ||
|
||
CREATE UNIQUE INDEX "studio_favorites_unique_idx" ON "studio_favorites" (studio_id, user_id); | ||
|
||
DROP INDEX studio_favorites_idx; | ||
|
||
ALTER TABLE "performer_favorites" ADD COLUMN "created_at" TIMESTAMP; | ||
ALTER TABLE "performer_favorites" ALTER "created_at" SET DEFAULT NOW(); | ||
ALTER TABLE "studio_favorites" ADD COLUMN "created_at" TIMESTAMP; | ||
ALTER TABLE "studio_favorites" ALTER "created_at" SET DEFAULT NOW(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters