Skip to content

Commit

Permalink
Merge pull request #61 from dcramer/feat/refactor-friends
Browse files Browse the repository at this point in the history
feat: Simplify friendships
  • Loading branch information
dcramer authored Sep 13, 2023
2 parents 98f5b51 + 67af80f commit 6596733
Show file tree
Hide file tree
Showing 52 changed files with 2,224 additions and 1,010 deletions.
21 changes: 21 additions & 0 deletions apps/api/migrations/0052_jittery_turbo.sql
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";
Loading

0 comments on commit 6596733

Please sign in to comment.