1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/drizzle/0005_magical_swarm.sql

19 lines
781 B
MySQL
Raw Normal View History

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 $$;