Skip to content

Commit

Permalink
feat: onDelete cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
bepyan committed Aug 20, 2024
1 parent ecb4c46 commit ff44443
Show file tree
Hide file tree
Showing 8 changed files with 438 additions and 17 deletions.
24 changes: 24 additions & 0 deletions src/lib/db/migrations/0003_flippant_the_professor.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ALTER TABLE "session" DROP CONSTRAINT "session_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "invitation_response" DROP CONSTRAINT "invitation_response_invitation_id_invitation_id_fk";
--> statement-breakpoint
ALTER TABLE "invitation" DROP CONSTRAINT "invitation_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "invitation_response" ALTER COLUMN "invitation_id" SET NOT NULL;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "invitation_response" ADD CONSTRAINT "invitation_response_invitation_id_invitation_id_fk" FOREIGN KEY ("invitation_id") REFERENCES "public"."invitation"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "invitation" ADD CONSTRAINT "invitation_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading

0 comments on commit ff44443

Please sign in to comment.