mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Generate migration
This commit is contained in:
parent
c40f086244
commit
4c91462b05
45
api/drizzle/0001_shows.sql
Normal file
45
api/drizzle/0001_shows.sql
Normal file
@ -0,0 +1,45 @@
|
||||
--> statement-breakpoint
|
||||
CREATE TYPE "kyoo"."genres" AS ENUM('action', 'adventure', 'animation', 'comedy', 'crime', 'documentary', 'drama', 'family', 'fantasy', 'history', 'horror', 'music', 'mystery', 'romance', 'science-fiction', 'thriller', 'war', 'western', 'kids', 'reality', 'politics', 'soap', 'talk');--> statement-breakpoint
|
||||
CREATE TYPE "kyoo"."show_kind" AS ENUM('serie', 'movie');--> statement-breakpoint
|
||||
CREATE TYPE "kyoo"."show_status" AS ENUM('unknown', 'finished', 'airing', 'planned');--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "kyoo"."show_translations" (
|
||||
"pk" integer NOT NULL,
|
||||
"language" varchar(255) NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"description" text,
|
||||
"tagline" text,
|
||||
"aliases" text[] NOT NULL,
|
||||
"tags" text[] NOT NULL,
|
||||
"trailerUrl" text,
|
||||
"poster" jsonb,
|
||||
"thumbnail" jsonb,
|
||||
"banner" jsonb,
|
||||
"logo" jsonb,
|
||||
CONSTRAINT "show_translations_pk_language_pk" PRIMARY KEY("pk","language")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "kyoo"."shows" (
|
||||
"pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."shows_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,
|
||||
"kind" "kyoo"."show_kind" NOT NULL,
|
||||
"genres" genres[] NOT NULL,
|
||||
"rating" smallint,
|
||||
"status" "kyoo"."show_status" NOT NULL,
|
||||
"startAir" date,
|
||||
"endAir" date,
|
||||
"originalLanguage" varchar(255),
|
||||
"externalId" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"createdAt" timestamp with time zone DEFAULT now(),
|
||||
"nextRefresh" timestamp with time zone,
|
||||
CONSTRAINT "shows_id_unique" UNIQUE("id"),
|
||||
CONSTRAINT "shows_slug_unique" UNIQUE("slug"),
|
||||
CONSTRAINT "ratingValid" CHECK (0 <= "shows"."rating" && "shows"."rating" <= 100)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "kyoo"."entries" ADD COLUMN "createdAt" timestamp with time zone DEFAULT now();--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "kyoo"."show_translations" ADD CONSTRAINT "show_translations_pk_shows_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."shows"("pk") ON DELETE cascade ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
491
api/drizzle/meta/0001_snapshot.json
Normal file
491
api/drizzle/meta/0001_snapshot.json
Normal file
@ -0,0 +1,491 @@
|
||||
{
|
||||
"id": "0f48a319-94fe-4bcc-b63c-28ce280abc9a",
|
||||
"prevId": "362abc74-1487-46ff-bfe2-203ea699f19e",
|
||||
"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
|
||||
},
|
||||
"externalId": {
|
||||
"name": "externalId",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'{}'::jsonb"
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"nextRefresh": {
|
||||
"name": "nextRefresh",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"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": {}
|
||||
},
|
||||
"kyoo.show_translations": {
|
||||
"name": "show_translations",
|
||||
"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": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"tagline": {
|
||||
"name": "tagline",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"aliases": {
|
||||
"name": "aliases",
|
||||
"type": "text[]",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"tags": {
|
||||
"name": "tags",
|
||||
"type": "text[]",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"trailerUrl": {
|
||||
"name": "trailerUrl",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"poster": {
|
||||
"name": "poster",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"thumbnail": {
|
||||
"name": "thumbnail",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"banner": {
|
||||
"name": "banner",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"logo": {
|
||||
"name": "logo",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"show_translations_pk_shows_pk_fk": {
|
||||
"name": "show_translations_pk_shows_pk_fk",
|
||||
"tableFrom": "show_translations",
|
||||
"tableTo": "shows",
|
||||
"schemaTo": "kyoo",
|
||||
"columnsFrom": [
|
||||
"pk"
|
||||
],
|
||||
"columnsTo": [
|
||||
"pk"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"show_translations_pk_language_pk": {
|
||||
"name": "show_translations_pk_language_pk",
|
||||
"columns": [
|
||||
"pk",
|
||||
"language"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"checkConstraints": {}
|
||||
},
|
||||
"kyoo.shows": {
|
||||
"name": "shows",
|
||||
"schema": "kyoo",
|
||||
"columns": {
|
||||
"pk": {
|
||||
"name": "pk",
|
||||
"type": "integer",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"identity": {
|
||||
"type": "always",
|
||||
"name": "shows_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
|
||||
},
|
||||
"kind": {
|
||||
"name": "kind",
|
||||
"type": "show_kind",
|
||||
"typeSchema": "kyoo",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"genres": {
|
||||
"name": "genres",
|
||||
"type": "genres[]",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"rating": {
|
||||
"name": "rating",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "show_status",
|
||||
"typeSchema": "kyoo",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"startAir": {
|
||||
"name": "startAir",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"endAir": {
|
||||
"name": "endAir",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"originalLanguage": {
|
||||
"name": "originalLanguage",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"externalId": {
|
||||
"name": "externalId",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'{}'::jsonb"
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"nextRefresh": {
|
||||
"name": "nextRefresh",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"shows_id_unique": {
|
||||
"name": "shows_id_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"shows_slug_unique": {
|
||||
"name": "shows_slug_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"slug"
|
||||
]
|
||||
}
|
||||
},
|
||||
"checkConstraints": {
|
||||
"ratingValid": {
|
||||
"name": "ratingValid",
|
||||
"value": "0 <= \"shows\".\"rating\" && \"shows\".\"rating\" <= 100"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"enums": {
|
||||
"kyoo.entry_type": {
|
||||
"name": "entry_type",
|
||||
"schema": "kyoo",
|
||||
"values": [
|
||||
"unknown",
|
||||
"episode",
|
||||
"movie",
|
||||
"special",
|
||||
"extra"
|
||||
]
|
||||
},
|
||||
"kyoo.genres": {
|
||||
"name": "genres",
|
||||
"schema": "kyoo",
|
||||
"values": [
|
||||
"action",
|
||||
"adventure",
|
||||
"animation",
|
||||
"comedy",
|
||||
"crime",
|
||||
"documentary",
|
||||
"drama",
|
||||
"family",
|
||||
"fantasy",
|
||||
"history",
|
||||
"horror",
|
||||
"music",
|
||||
"mystery",
|
||||
"romance",
|
||||
"science-fiction",
|
||||
"thriller",
|
||||
"war",
|
||||
"western",
|
||||
"kids",
|
||||
"reality",
|
||||
"politics",
|
||||
"soap",
|
||||
"talk"
|
||||
]
|
||||
},
|
||||
"kyoo.show_kind": {
|
||||
"name": "show_kind",
|
||||
"schema": "kyoo",
|
||||
"values": [
|
||||
"serie",
|
||||
"movie"
|
||||
]
|
||||
},
|
||||
"kyoo.show_status": {
|
||||
"name": "show_status",
|
||||
"schema": "kyoo",
|
||||
"values": [
|
||||
"unknown",
|
||||
"finished",
|
||||
"airing",
|
||||
"planned"
|
||||
]
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"kyoo": "kyoo"
|
||||
},
|
||||
"sequences": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
@ -8,6 +8,13 @@
|
||||
"when": 1730060281406,
|
||||
"tag": "0000_init",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "7",
|
||||
"when": 1730477283024,
|
||||
"tag": "0001_shows",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
@ -34,8 +34,11 @@ export const entries = schema.table(
|
||||
airDate: date(),
|
||||
runtime: integer(),
|
||||
thumbnails: jsonb(),
|
||||
nextRefresh: timestamp({ withTimezone: true }),
|
||||
|
||||
externalId: jsonb().notNull().default({}),
|
||||
|
||||
createdAt: timestamp({ withTimezone: true }).defaultNow(),
|
||||
nextRefresh: timestamp({ withTimezone: true }),
|
||||
},
|
||||
(t) => ({
|
||||
// episodeKey: unique().on(t.showId, t.seasonNumber, t.episodeNumber),
|
||||
|
@ -57,7 +57,7 @@ export const shows = schema.table(
|
||||
|
||||
externalId: jsonb().notNull().default({}),
|
||||
|
||||
createdAt: timestamp({ withTimezone: true }),
|
||||
createdAt: timestamp({ withTimezone: true }).defaultNow(),
|
||||
nextRefresh: timestamp({ withTimezone: true }),
|
||||
},
|
||||
(t) => ({
|
||||
|
Loading…
x
Reference in New Issue
Block a user