mirror of
https://git.sr.ht/~roxwize/mipilin
synced 2025-01-31 02:53:36 +00:00
19 lines
781 B
MySQL
19 lines
781 B
MySQL
|
CREATE TABLE IF NOT EXISTS "follows" (
|
||
|
"user_id" integer,
|
||
|
"follower_id" integer,
|
||
|
CONSTRAINT "follows_user_id_follower_id_pk" PRIMARY KEY("user_id","follower_id")
|
||
|
);
|
||
|
--> statement-breakpoint
|
||
|
ALTER TABLE "profiles" ADD COLUMN "website" varchar DEFAULT '' NOT NULL;--> statement-breakpoint
|
||
|
DO $$ BEGIN
|
||
|
ALTER TABLE "follows" ADD CONSTRAINT "follows_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||
|
EXCEPTION
|
||
|
WHEN duplicate_object THEN null;
|
||
|
END $$;
|
||
|
--> statement-breakpoint
|
||
|
DO $$ BEGIN
|
||
|
ALTER TABLE "follows" ADD CONSTRAINT "follows_follower_id_users_id_fk" FOREIGN KEY ("follower_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
||
|
EXCEPTION
|
||
|
WHEN duplicate_object THEN null;
|
||
|
END $$;
|