Files
image-platform/packages/database/drizzle/0002_grey_ser_duncan.sql

14 lines
941 B
MySQL
Raw Normal View History

2026-05-12 07:54:32 +03:00
CREATE TYPE "public"."project_status" AS ENUM('active', 'disabled');--> statement-breakpoint
CREATE TABLE "image_projects" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"slug" text NOT NULL,
"name" text NOT NULL,
"status" "project_status" DEFAULT 'active' NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "image_assets" ADD COLUMN "project_id" uuid;--> statement-breakpoint
CREATE UNIQUE INDEX "image_projects_slug_idx" ON "image_projects" USING btree ("slug");--> statement-breakpoint
ALTER TABLE "image_assets" ADD CONSTRAINT "image_assets_project_id_image_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."image_projects"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "image_assets_project_id_idx" ON "image_assets" USING btree ("project_id");