diff --git a/api/drizzle/0000_init.sql b/api/drizzle/0000_init.sql new file mode 100644 index 00000000..dc4826ad --- /dev/null +++ b/api/drizzle/0000_init.sql @@ -0,0 +1,32 @@ +CREATE TYPE "kyoo"."entry_type" AS ENUM('unknown', 'episode', 'movie', 'special', 'extra');--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "kyoo"."entries" ( + "pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."entries_pk_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "id" uuid DEFAULT gen_random_uuid() NOT NULL, + "slug" varchar(255) NOT NULL, + "order" integer NOT NULL, + "seasonNumber" integer, + "episodeNumber" integer, + "type" "kyoo"."entry_type" NOT NULL, + "airDate" date, + "runtime" integer, + "thumbnails" jsonb, + "nextRefresh" timestamp with time zone, + "externalId" jsonb DEFAULT '{}'::jsonb NOT NULL, + CONSTRAINT "entries_id_unique" UNIQUE("id"), + CONSTRAINT "entries_slug_unique" UNIQUE("slug"), + CONSTRAINT "orderPositive" CHECK ("entries"."order" >= 0) +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "kyoo"."entries_translation" ( + "pk" integer NOT NULL, + "language" varchar(255) NOT NULL, + "name" text, + "description" text, + CONSTRAINT "entries_translation_pk_language_pk" PRIMARY KEY("pk","language") +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "kyoo"."entries_translation" ADD CONSTRAINT "entries_translation_pk_entries_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."entries"("pk") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/api/drizzle/meta/0000_snapshot.json b/api/drizzle/meta/0000_snapshot.json new file mode 100644 index 00000000..7e59d589 --- /dev/null +++ b/api/drizzle/meta/0000_snapshot.json @@ -0,0 +1,204 @@ +{ + "id": "362abc74-1487-46ff-bfe2-203ea699f19e", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "kyoo.entries": { + "name": "entries", + "schema": "kyoo", + "columns": { + "pk": { + "name": "pk", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "entries_pk_seq", + "schema": "kyoo", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "seasonNumber": { + "name": "seasonNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "episodeNumber": { + "name": "episodeNumber", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "entry_type", + "typeSchema": "kyoo", + "primaryKey": false, + "notNull": true + }, + "airDate": { + "name": "airDate", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "runtime": { + "name": "runtime", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "thumbnails": { + "name": "thumbnails", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nextRefresh": { + "name": "nextRefresh", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "externalId": { + "name": "externalId", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "entries_id_unique": { + "name": "entries_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + }, + "entries_slug_unique": { + "name": "entries_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "checkConstraints": { + "orderPositive": { + "name": "orderPositive", + "value": "\"entries\".\"order\" >= 0" + } + } + }, + "kyoo.entries_translation": { + "name": "entries_translation", + "schema": "kyoo", + "columns": { + "pk": { + "name": "pk", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "language": { + "name": "language", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "entries_translation_pk_entries_pk_fk": { + "name": "entries_translation_pk_entries_pk_fk", + "tableFrom": "entries_translation", + "tableTo": "entries", + "schemaTo": "kyoo", + "columnsFrom": [ + "pk" + ], + "columnsTo": [ + "pk" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "entries_translation_pk_language_pk": { + "name": "entries_translation_pk_language_pk", + "columns": [ + "pk", + "language" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "enums": { + "kyoo.entry_type": { + "name": "entry_type", + "schema": "kyoo", + "values": [ + "unknown", + "episode", + "movie", + "special", + "extra" + ] + } + }, + "schemas": {}, + "sequences": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/api/drizzle/meta/_journal.json b/api/drizzle/meta/_journal.json new file mode 100644 index 00000000..6c51b6b4 --- /dev/null +++ b/api/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1730060281406, + "tag": "0000_init", + "breakpoints": true + } + ] +} \ No newline at end of file