Skip to content

Commit 9008d63

Browse files
committed
Adding images
New Migration
1 parent 550d61e commit 9008d63

File tree

17 files changed

+9689
-3
lines changed

17 files changed

+9689
-3
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
CREATE TABLE IF NOT EXISTS "galleries" (
2+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
3+
"name" text NOT NULL,
4+
"description" text,
5+
"event_id" uuid,
6+
"slug" text NOT NULL,
7+
"created_at" timestamp (6) DEFAULT now() NOT NULL,
8+
"updated_at" timestamp (6),
9+
"deleted_at" timestamp (6),
10+
CONSTRAINT "galleries_id_unique" UNIQUE("id"),
11+
CONSTRAINT "galleries_slug_unique" UNIQUE("slug")
12+
);
13+
--> statement-breakpoint
14+
CREATE TABLE IF NOT EXISTS "images" (
15+
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
16+
"image_url" text NOT NULL,
17+
"hosting" text NOT NULL,
18+
"gallery_id" uuid,
19+
"tags" text[] DEFAULT ARRAY[]::text[] NOT NULL,
20+
"created_at" timestamp (6) DEFAULT now() NOT NULL,
21+
"updated_at" timestamp (6),
22+
"deleted_at" timestamp (6),
23+
CONSTRAINT "images_id_unique" UNIQUE("id")
24+
);
25+
--> statement-breakpoint
26+
DO $$ BEGIN
27+
ALTER TABLE "galleries" ADD CONSTRAINT "galleries_event_id_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."events"("id") ON DELETE no action ON UPDATE no action;
28+
EXCEPTION
29+
WHEN duplicate_object THEN null;
30+
END $$;
31+
--> statement-breakpoint
32+
DO $$ BEGIN
33+
ALTER TABLE "galleries" ADD CONSTRAINT "galleries_slug_tags_id_fk" FOREIGN KEY ("slug") REFERENCES "public"."tags"("id") ON DELETE no action ON UPDATE no action;
34+
EXCEPTION
35+
WHEN duplicate_object THEN null;
36+
END $$;
37+
--> statement-breakpoint
38+
DO $$ BEGIN
39+
ALTER TABLE "images" ADD CONSTRAINT "images_gallery_id_galleries_id_fk" FOREIGN KEY ("gallery_id") REFERENCES "public"."galleries"("id") ON DELETE no action ON UPDATE no action;
40+
EXCEPTION
41+
WHEN duplicate_object THEN null;
42+
END $$;
43+
--> statement-breakpoint
44+
CREATE INDEX IF NOT EXISTS "gallery_slug_index" ON "galleries" USING btree ("slug");--> statement-breakpoint
45+
CREATE INDEX IF NOT EXISTS "images_tags_index" ON "images" USING btree ("tags");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "galleries" DROP CONSTRAINT "galleries_slug_tags_id_fk";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP INDEX IF EXISTS "gallery_slug_index";

0 commit comments

Comments
 (0)