-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from dcramer/feat/refactor-friends
feat: Simplify friendships
- Loading branch information
Showing
52 changed files
with
2,224 additions
and
1,010 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DO $$ BEGIN | ||
CREATE TYPE "notification_type" AS ENUM('comment', 'toast', 'friend_request'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
DO $$ BEGIN | ||
CREATE TYPE "notification_type_temp" AS ENUM('comment', 'toast', 'friend_request', 'follow'); | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
|
||
|
||
ALTER TABLE "notifications" RENAME COLUMN "object_type" TO "type"; | ||
DROP INDEX IF EXISTS "notifications_unq"; | ||
ALTER TABLE "notifications" ALTER COLUMN "type" SET DATA TYPE notification_type_temp USING type::text::notification_type_temp; | ||
CREATE UNIQUE INDEX IF NOT EXISTS "notifications_unq" ON "notifications" ("user_id","object_id","type","created_at"); | ||
|
||
UPDATE "notifications" set "type" = 'friend_request' WHERE "type" = 'follow'; | ||
ALTER TABLE "notifications" ALTER COLUMN "type" SET DATA TYPE notification_type USING type::text::notification_type; | ||
DROP TYPE "notification_type_temp"; |
Oops, something went wrong.