Files
website/drizzle/20261027094025_media_webtoon_meta/migration.sql
T

19 lines
1.3 KiB
SQL

CREATE TABLE "media"."covers" (
"item_id" integer PRIMARY KEY,
"mime" text NOT NULL,
"bytes" bytea NOT NULL,
"source_url" text,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "covers_mime_check" CHECK ("mime" IN ('image/jpeg','image/png','image/webp','image/gif')),
CONSTRAINT "covers_size_check" CHECK (octet_length("bytes") BETWEEN 1 AND 2000000)
);
--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "title_en" text;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "artist" text;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "synopsis" text;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "year_start" integer;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "year_end" integer;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "adaptation" text;--> statement-breakpoint
ALTER TABLE "media"."items" ADD COLUMN "source_ref" text;--> statement-breakpoint
ALTER TABLE "media"."covers" ADD CONSTRAINT "covers_item_id_items_id_fkey" FOREIGN KEY ("item_id") REFERENCES "media"."items"("id") ON DELETE CASCADE;--> statement-breakpoint
ALTER TABLE "media"."items" ADD CONSTRAINT "items_years_check" CHECK (("year_start" IS NULL OR "year_start" BETWEEN 1900 AND 2100) AND ("year_end" IS NULL OR "year_end" BETWEEN 1900 AND 2100));