Type json in drizzle schemas

This commit is contained in:
Zoe Roux 2024-11-01 21:47:18 +01:00
parent 908e06c88f
commit ed5d677ae1
No known key found for this signature in database
8 changed files with 1163 additions and 727 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE "kyoo"."shows" ALTER COLUMN "createdAt" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "kyoo"."shows" ALTER COLUMN "nextRefresh" SET NOT NULL;

View File

@ -1,204 +1,187 @@
{ {
"id": "362abc74-1487-46ff-bfe2-203ea699f19e", "id": "362abc74-1487-46ff-bfe2-203ea699f19e",
"prevId": "00000000-0000-0000-0000-000000000000", "prevId": "00000000-0000-0000-0000-000000000000",
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",
"tables": { "tables": {
"kyoo.entries": { "kyoo.entries": {
"name": "entries", "name": "entries",
"schema": "kyoo", "schema": "kyoo",
"columns": { "columns": {
"pk": { "pk": {
"name": "pk", "name": "pk",
"type": "integer", "type": "integer",
"primaryKey": true, "primaryKey": true,
"notNull": true, "notNull": true,
"identity": { "identity": {
"type": "always", "type": "always",
"name": "entries_pk_seq", "name": "entries_pk_seq",
"schema": "kyoo", "schema": "kyoo",
"increment": "1", "increment": "1",
"startWith": "1", "startWith": "1",
"minValue": "1", "minValue": "1",
"maxValue": "2147483647", "maxValue": "2147483647",
"cache": "1", "cache": "1",
"cycle": false "cycle": false
} }
}, },
"id": { "id": {
"name": "id", "name": "id",
"type": "uuid", "type": "uuid",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"default": "gen_random_uuid()" "default": "gen_random_uuid()"
}, },
"slug": { "slug": {
"name": "slug", "name": "slug",
"type": "varchar(255)", "type": "varchar(255)",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"order": { "order": {
"name": "order", "name": "order",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"seasonNumber": { "seasonNumber": {
"name": "seasonNumber", "name": "seasonNumber",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"episodeNumber": { "episodeNumber": {
"name": "episodeNumber", "name": "episodeNumber",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"type": { "type": {
"name": "type", "name": "type",
"type": "entry_type", "type": "entry_type",
"typeSchema": "kyoo", "typeSchema": "kyoo",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"airDate": { "airDate": {
"name": "airDate", "name": "airDate",
"type": "date", "type": "date",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"runtime": { "runtime": {
"name": "runtime", "name": "runtime",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"thumbnails": { "thumbnails": {
"name": "thumbnails", "name": "thumbnails",
"type": "jsonb", "type": "jsonb",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"nextRefresh": { "nextRefresh": {
"name": "nextRefresh", "name": "nextRefresh",
"type": "timestamp with time zone", "type": "timestamp with time zone",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"externalId": { "externalId": {
"name": "externalId", "name": "externalId",
"type": "jsonb", "type": "jsonb",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"default": "'{}'::jsonb" "default": "'{}'::jsonb"
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": {}, "foreignKeys": {},
"compositePrimaryKeys": {}, "compositePrimaryKeys": {},
"uniqueConstraints": { "uniqueConstraints": {
"entries_id_unique": { "entries_id_unique": {
"name": "entries_id_unique", "name": "entries_id_unique",
"nullsNotDistinct": false, "nullsNotDistinct": false,
"columns": [ "columns": ["id"]
"id" },
] "entries_slug_unique": {
}, "name": "entries_slug_unique",
"entries_slug_unique": { "nullsNotDistinct": false,
"name": "entries_slug_unique", "columns": ["slug"]
"nullsNotDistinct": false, }
"columns": [ },
"slug" "checkConstraints": {
] "orderPositive": {
} "name": "orderPositive",
}, "value": "\"entries\".\"order\" >= 0"
"checkConstraints": { }
"orderPositive": { }
"name": "orderPositive", },
"value": "\"entries\".\"order\" >= 0" "kyoo.entries_translation": {
} "name": "entries_translation",
} "schema": "kyoo",
}, "columns": {
"kyoo.entries_translation": { "pk": {
"name": "entries_translation", "name": "pk",
"schema": "kyoo", "type": "integer",
"columns": { "primaryKey": false,
"pk": { "notNull": true
"name": "pk", },
"type": "integer", "language": {
"primaryKey": false, "name": "language",
"notNull": true "type": "varchar(255)",
}, "primaryKey": false,
"language": { "notNull": true
"name": "language", },
"type": "varchar(255)", "name": {
"primaryKey": false, "name": "name",
"notNull": true "type": "text",
}, "primaryKey": false,
"name": { "notNull": false
"name": "name", },
"type": "text", "description": {
"primaryKey": false, "name": "description",
"notNull": false "type": "text",
}, "primaryKey": false,
"description": { "notNull": false
"name": "description", }
"type": "text", },
"primaryKey": false, "indexes": {},
"notNull": false "foreignKeys": {
} "entries_translation_pk_entries_pk_fk": {
}, "name": "entries_translation_pk_entries_pk_fk",
"indexes": {}, "tableFrom": "entries_translation",
"foreignKeys": { "tableTo": "entries",
"entries_translation_pk_entries_pk_fk": { "schemaTo": "kyoo",
"name": "entries_translation_pk_entries_pk_fk", "columnsFrom": ["pk"],
"tableFrom": "entries_translation", "columnsTo": ["pk"],
"tableTo": "entries", "onDelete": "cascade",
"schemaTo": "kyoo", "onUpdate": "no action"
"columnsFrom": [ }
"pk" },
], "compositePrimaryKeys": {
"columnsTo": [ "entries_translation_pk_language_pk": {
"pk" "name": "entries_translation_pk_language_pk",
], "columns": ["pk", "language"]
"onDelete": "cascade", }
"onUpdate": "no action" },
} "uniqueConstraints": {},
}, "checkConstraints": {}
"compositePrimaryKeys": { }
"entries_translation_pk_language_pk": { },
"name": "entries_translation_pk_language_pk", "enums": {
"columns": [ "kyoo.entry_type": {
"pk", "name": "entry_type",
"language" "schema": "kyoo",
] "values": ["unknown", "episode", "movie", "special", "extra"]
} }
}, },
"uniqueConstraints": {}, "schemas": {},
"checkConstraints": {} "sequences": {},
} "views": {},
}, "_meta": {
"enums": { "columns": {},
"kyoo.entry_type": { "schemas": {},
"name": "entry_type", "tables": {}
"schema": "kyoo", }
"values": [ }
"unknown",
"episode",
"movie",
"special",
"extra"
]
}
},
"schemas": {},
"sequences": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@ -1,491 +1,455 @@
{ {
"id": "0f48a319-94fe-4bcc-b63c-28ce280abc9a", "id": "0f48a319-94fe-4bcc-b63c-28ce280abc9a",
"prevId": "362abc74-1487-46ff-bfe2-203ea699f19e", "prevId": "362abc74-1487-46ff-bfe2-203ea699f19e",
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",
"tables": { "tables": {
"kyoo.entries": { "kyoo.entries": {
"name": "entries", "name": "entries",
"schema": "kyoo", "schema": "kyoo",
"columns": { "columns": {
"pk": { "pk": {
"name": "pk", "name": "pk",
"type": "integer", "type": "integer",
"primaryKey": true, "primaryKey": true,
"notNull": true, "notNull": true,
"identity": { "identity": {
"type": "always", "type": "always",
"name": "entries_pk_seq", "name": "entries_pk_seq",
"schema": "kyoo", "schema": "kyoo",
"increment": "1", "increment": "1",
"startWith": "1", "startWith": "1",
"minValue": "1", "minValue": "1",
"maxValue": "2147483647", "maxValue": "2147483647",
"cache": "1", "cache": "1",
"cycle": false "cycle": false
} }
}, },
"id": { "id": {
"name": "id", "name": "id",
"type": "uuid", "type": "uuid",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"default": "gen_random_uuid()" "default": "gen_random_uuid()"
}, },
"slug": { "slug": {
"name": "slug", "name": "slug",
"type": "varchar(255)", "type": "varchar(255)",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"order": { "order": {
"name": "order", "name": "order",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"seasonNumber": { "seasonNumber": {
"name": "seasonNumber", "name": "seasonNumber",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"episodeNumber": { "episodeNumber": {
"name": "episodeNumber", "name": "episodeNumber",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"type": { "type": {
"name": "type", "name": "type",
"type": "entry_type", "type": "entry_type",
"typeSchema": "kyoo", "typeSchema": "kyoo",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": true
}, },
"airDate": { "airDate": {
"name": "airDate", "name": "airDate",
"type": "date", "type": "date",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"runtime": { "runtime": {
"name": "runtime", "name": "runtime",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"thumbnails": { "thumbnails": {
"name": "thumbnails", "name": "thumbnails",
"type": "jsonb", "type": "jsonb",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
}, },
"externalId": { "externalId": {
"name": "externalId", "name": "externalId",
"type": "jsonb", "type": "jsonb",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"default": "'{}'::jsonb" "default": "'{}'::jsonb"
}, },
"createdAt": { "createdAt": {
"name": "createdAt", "name": "createdAt",
"type": "timestamp with time zone", "type": "timestamp with time zone",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"default": "now()" "default": "now()"
}, },
"nextRefresh": { "nextRefresh": {
"name": "nextRefresh", "name": "nextRefresh",
"type": "timestamp with time zone", "type": "timestamp with time zone",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": {}, "foreignKeys": {},
"compositePrimaryKeys": {}, "compositePrimaryKeys": {},
"uniqueConstraints": { "uniqueConstraints": {
"entries_id_unique": { "entries_id_unique": {
"name": "entries_id_unique", "name": "entries_id_unique",
"nullsNotDistinct": false, "nullsNotDistinct": false,
"columns": [ "columns": ["id"]
"id" },
] "entries_slug_unique": {
}, "name": "entries_slug_unique",
"entries_slug_unique": { "nullsNotDistinct": false,
"name": "entries_slug_unique", "columns": ["slug"]
"nullsNotDistinct": false, }
"columns": [ },
"slug" "checkConstraints": {
] "orderPositive": {
} "name": "orderPositive",
}, "value": "\"entries\".\"order\" >= 0"
"checkConstraints": { }
"orderPositive": { }
"name": "orderPositive", },
"value": "\"entries\".\"order\" >= 0" "kyoo.entries_translation": {
} "name": "entries_translation",
} "schema": "kyoo",
}, "columns": {
"kyoo.entries_translation": { "pk": {
"name": "entries_translation", "name": "pk",
"schema": "kyoo", "type": "integer",
"columns": { "primaryKey": false,
"pk": { "notNull": true
"name": "pk", },
"type": "integer", "language": {
"primaryKey": false, "name": "language",
"notNull": true "type": "varchar(255)",
}, "primaryKey": false,
"language": { "notNull": true
"name": "language", },
"type": "varchar(255)", "name": {
"primaryKey": false, "name": "name",
"notNull": true "type": "text",
}, "primaryKey": false,
"name": { "notNull": false
"name": "name", },
"type": "text", "description": {
"primaryKey": false, "name": "description",
"notNull": false "type": "text",
}, "primaryKey": false,
"description": { "notNull": false
"name": "description", }
"type": "text", },
"primaryKey": false, "indexes": {},
"notNull": false "foreignKeys": {
} "entries_translation_pk_entries_pk_fk": {
}, "name": "entries_translation_pk_entries_pk_fk",
"indexes": {}, "tableFrom": "entries_translation",
"foreignKeys": { "tableTo": "entries",
"entries_translation_pk_entries_pk_fk": { "schemaTo": "kyoo",
"name": "entries_translation_pk_entries_pk_fk", "columnsFrom": ["pk"],
"tableFrom": "entries_translation", "columnsTo": ["pk"],
"tableTo": "entries", "onDelete": "cascade",
"schemaTo": "kyoo", "onUpdate": "no action"
"columnsFrom": [ }
"pk" },
], "compositePrimaryKeys": {
"columnsTo": [ "entries_translation_pk_language_pk": {
"pk" "name": "entries_translation_pk_language_pk",
], "columns": ["pk", "language"]
"onDelete": "cascade", }
"onUpdate": "no action" },
} "uniqueConstraints": {},
}, "checkConstraints": {}
"compositePrimaryKeys": { },
"entries_translation_pk_language_pk": { "kyoo.show_translations": {
"name": "entries_translation_pk_language_pk", "name": "show_translations",
"columns": [ "schema": "kyoo",
"pk", "columns": {
"language" "pk": {
] "name": "pk",
} "type": "integer",
}, "primaryKey": false,
"uniqueConstraints": {}, "notNull": true
"checkConstraints": {} },
}, "language": {
"kyoo.show_translations": { "name": "language",
"name": "show_translations", "type": "varchar(255)",
"schema": "kyoo", "primaryKey": false,
"columns": { "notNull": true
"pk": { },
"name": "pk", "name": {
"type": "integer", "name": "name",
"primaryKey": false, "type": "text",
"notNull": true "primaryKey": false,
}, "notNull": true
"language": { },
"name": "language", "description": {
"type": "varchar(255)", "name": "description",
"primaryKey": false, "type": "text",
"notNull": true "primaryKey": false,
}, "notNull": false
"name": { },
"name": "name", "tagline": {
"type": "text", "name": "tagline",
"primaryKey": false, "type": "text",
"notNull": true "primaryKey": false,
}, "notNull": false
"description": { },
"name": "description", "aliases": {
"type": "text", "name": "aliases",
"primaryKey": false, "type": "text[]",
"notNull": false "primaryKey": false,
}, "notNull": true
"tagline": { },
"name": "tagline", "tags": {
"type": "text", "name": "tags",
"primaryKey": false, "type": "text[]",
"notNull": false "primaryKey": false,
}, "notNull": true
"aliases": { },
"name": "aliases", "trailerUrl": {
"type": "text[]", "name": "trailerUrl",
"primaryKey": false, "type": "text",
"notNull": true "primaryKey": false,
}, "notNull": false
"tags": { },
"name": "tags", "poster": {
"type": "text[]", "name": "poster",
"primaryKey": false, "type": "jsonb",
"notNull": true "primaryKey": false,
}, "notNull": false
"trailerUrl": { },
"name": "trailerUrl", "thumbnail": {
"type": "text", "name": "thumbnail",
"primaryKey": false, "type": "jsonb",
"notNull": false "primaryKey": false,
}, "notNull": false
"poster": { },
"name": "poster", "banner": {
"type": "jsonb", "name": "banner",
"primaryKey": false, "type": "jsonb",
"notNull": false "primaryKey": false,
}, "notNull": false
"thumbnail": { },
"name": "thumbnail", "logo": {
"type": "jsonb", "name": "logo",
"primaryKey": false, "type": "jsonb",
"notNull": false "primaryKey": false,
}, "notNull": false
"banner": { }
"name": "banner", },
"type": "jsonb", "indexes": {},
"primaryKey": false, "foreignKeys": {
"notNull": false "show_translations_pk_shows_pk_fk": {
}, "name": "show_translations_pk_shows_pk_fk",
"logo": { "tableFrom": "show_translations",
"name": "logo", "tableTo": "shows",
"type": "jsonb", "schemaTo": "kyoo",
"primaryKey": false, "columnsFrom": ["pk"],
"notNull": false "columnsTo": ["pk"],
} "onDelete": "cascade",
}, "onUpdate": "no action"
"indexes": {}, }
"foreignKeys": { },
"show_translations_pk_shows_pk_fk": { "compositePrimaryKeys": {
"name": "show_translations_pk_shows_pk_fk", "show_translations_pk_language_pk": {
"tableFrom": "show_translations", "name": "show_translations_pk_language_pk",
"tableTo": "shows", "columns": ["pk", "language"]
"schemaTo": "kyoo", }
"columnsFrom": [ },
"pk" "uniqueConstraints": {},
], "checkConstraints": {}
"columnsTo": [ },
"pk" "kyoo.shows": {
], "name": "shows",
"onDelete": "cascade", "schema": "kyoo",
"onUpdate": "no action" "columns": {
} "pk": {
}, "name": "pk",
"compositePrimaryKeys": { "type": "integer",
"show_translations_pk_language_pk": { "primaryKey": true,
"name": "show_translations_pk_language_pk", "notNull": true,
"columns": [ "identity": {
"pk", "type": "always",
"language" "name": "shows_pk_seq",
] "schema": "kyoo",
} "increment": "1",
}, "startWith": "1",
"uniqueConstraints": {}, "minValue": "1",
"checkConstraints": {} "maxValue": "2147483647",
}, "cache": "1",
"kyoo.shows": { "cycle": false
"name": "shows", }
"schema": "kyoo", },
"columns": { "id": {
"pk": { "name": "id",
"name": "pk", "type": "uuid",
"type": "integer", "primaryKey": false,
"primaryKey": true, "notNull": true,
"notNull": true, "default": "gen_random_uuid()"
"identity": { },
"type": "always", "slug": {
"name": "shows_pk_seq", "name": "slug",
"schema": "kyoo", "type": "varchar(255)",
"increment": "1", "primaryKey": false,
"startWith": "1", "notNull": true
"minValue": "1", },
"maxValue": "2147483647", "kind": {
"cache": "1", "name": "kind",
"cycle": false "type": "show_kind",
} "typeSchema": "kyoo",
}, "primaryKey": false,
"id": { "notNull": true
"name": "id", },
"type": "uuid", "genres": {
"primaryKey": false, "name": "genres",
"notNull": true, "type": "genres[]",
"default": "gen_random_uuid()" "primaryKey": false,
}, "notNull": true
"slug": { },
"name": "slug", "rating": {
"type": "varchar(255)", "name": "rating",
"primaryKey": false, "type": "smallint",
"notNull": true "primaryKey": false,
}, "notNull": false
"kind": { },
"name": "kind", "status": {
"type": "show_kind", "name": "status",
"typeSchema": "kyoo", "type": "show_status",
"primaryKey": false, "typeSchema": "kyoo",
"notNull": true "primaryKey": false,
}, "notNull": true
"genres": { },
"name": "genres", "startAir": {
"type": "genres[]", "name": "startAir",
"primaryKey": false, "type": "date",
"notNull": true "primaryKey": false,
}, "notNull": false
"rating": { },
"name": "rating", "endAir": {
"type": "smallint", "name": "endAir",
"primaryKey": false, "type": "date",
"notNull": false "primaryKey": false,
}, "notNull": false
"status": { },
"name": "status", "originalLanguage": {
"type": "show_status", "name": "originalLanguage",
"typeSchema": "kyoo", "type": "varchar(255)",
"primaryKey": false, "primaryKey": false,
"notNull": true "notNull": false
}, },
"startAir": { "externalId": {
"name": "startAir", "name": "externalId",
"type": "date", "type": "jsonb",
"primaryKey": false, "primaryKey": false,
"notNull": false "notNull": true,
}, "default": "'{}'::jsonb"
"endAir": { },
"name": "endAir", "createdAt": {
"type": "date", "name": "createdAt",
"primaryKey": false, "type": "timestamp with time zone",
"notNull": false "primaryKey": false,
}, "notNull": false,
"originalLanguage": { "default": "now()"
"name": "originalLanguage", },
"type": "varchar(255)", "nextRefresh": {
"primaryKey": false, "name": "nextRefresh",
"notNull": false "type": "timestamp with time zone",
}, "primaryKey": false,
"externalId": { "notNull": false
"name": "externalId", }
"type": "jsonb", },
"primaryKey": false, "indexes": {},
"notNull": true, "foreignKeys": {},
"default": "'{}'::jsonb" "compositePrimaryKeys": {},
}, "uniqueConstraints": {
"createdAt": { "shows_id_unique": {
"name": "createdAt", "name": "shows_id_unique",
"type": "timestamp with time zone", "nullsNotDistinct": false,
"primaryKey": false, "columns": ["id"]
"notNull": false, },
"default": "now()" "shows_slug_unique": {
}, "name": "shows_slug_unique",
"nextRefresh": { "nullsNotDistinct": false,
"name": "nextRefresh", "columns": ["slug"]
"type": "timestamp with time zone", }
"primaryKey": false, },
"notNull": false "checkConstraints": {
} "ratingValid": {
}, "name": "ratingValid",
"indexes": {}, "value": "0 <= \"shows\".\"rating\" && \"shows\".\"rating\" <= 100"
"foreignKeys": {}, }
"compositePrimaryKeys": {}, }
"uniqueConstraints": { }
"shows_id_unique": { },
"name": "shows_id_unique", "enums": {
"nullsNotDistinct": false, "kyoo.entry_type": {
"columns": [ "name": "entry_type",
"id" "schema": "kyoo",
] "values": ["unknown", "episode", "movie", "special", "extra"]
}, },
"shows_slug_unique": { "kyoo.genres": {
"name": "shows_slug_unique", "name": "genres",
"nullsNotDistinct": false, "schema": "kyoo",
"columns": [ "values": [
"slug" "action",
] "adventure",
} "animation",
}, "comedy",
"checkConstraints": { "crime",
"ratingValid": { "documentary",
"name": "ratingValid", "drama",
"value": "0 <= \"shows\".\"rating\" && \"shows\".\"rating\" <= 100" "family",
} "fantasy",
} "history",
} "horror",
}, "music",
"enums": { "mystery",
"kyoo.entry_type": { "romance",
"name": "entry_type", "science-fiction",
"schema": "kyoo", "thriller",
"values": [ "war",
"unknown", "western",
"episode", "kids",
"movie", "reality",
"special", "politics",
"extra" "soap",
] "talk"
}, ]
"kyoo.genres": { },
"name": "genres", "kyoo.show_kind": {
"schema": "kyoo", "name": "show_kind",
"values": [ "schema": "kyoo",
"action", "values": ["serie", "movie"]
"adventure", },
"animation", "kyoo.show_status": {
"comedy", "name": "show_status",
"crime", "schema": "kyoo",
"documentary", "values": ["unknown", "finished", "airing", "planned"]
"drama", }
"family", },
"fantasy", "schemas": {
"history", "kyoo": "kyoo"
"horror", },
"music", "sequences": {},
"mystery", "views": {},
"romance", "_meta": {
"science-fiction", "columns": {},
"thriller", "schemas": {},
"war", "tables": {}
"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": {}
}
}

View File

@ -0,0 +1,455 @@
{
"id": "1948acaf-7a29-4521-988d-439653779e39",
"prevId": "0f48a319-94fe-4bcc-b63c-28ce280abc9a",
"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": true,
"default": "now()"
},
"nextRefresh": {
"name": "nextRefresh",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
}
},
"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": {}
}
}

View File

@ -1,20 +1,27 @@
{ {
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",
"entries": [ "entries": [
{ {
"idx": 0, "idx": 0,
"version": "7", "version": "7",
"when": 1730060281406, "when": 1730060281406,
"tag": "0000_init", "tag": "0000_init",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 1, "idx": 1,
"version": "7", "version": "7",
"when": 1730477283024, "when": 1730477283024,
"tag": "0001_shows", "tag": "0001_shows",
"breakpoints": true "breakpoints": true
} },
] {
} "idx": 2,
"version": "7",
"when": 1730487641214,
"tag": "0002_shows",
"breakpoints": true
}
]
}

View File

@ -10,7 +10,7 @@ import {
uuid, uuid,
varchar, varchar,
} from "drizzle-orm/pg-core"; } from "drizzle-orm/pg-core";
import { language, schema } from "./utils"; import { image, language, schema } from "./utils";
export const entryType = schema.enum("entry_type", [ export const entryType = schema.enum("entry_type", [
"unknown", "unknown",
@ -33,7 +33,7 @@ export const entries = schema.table(
type: entryType().notNull(), type: entryType().notNull(),
airDate: date(), airDate: date(),
runtime: integer(), runtime: integer(),
thumbnails: jsonb(), thumbnails: image(),
externalId: jsonb().notNull().default({}), externalId: jsonb().notNull().default({}),

View File

@ -11,10 +11,15 @@ import {
uuid, uuid,
varchar, varchar,
} from "drizzle-orm/pg-core"; } from "drizzle-orm/pg-core";
import { language, schema } from "./utils"; import { externalid, image, language, schema } from "./utils";
export const showKind = schema.enum("show_kind", ["serie", "movie"]); export const showKind = schema.enum("show_kind", ["serie", "movie"]);
export const showStatus = schema.enum("show_status", ["unknown", "finished", "airing", "planned"]); export const showStatus = schema.enum("show_status", [
"unknown",
"finished",
"airing",
"planned",
]);
export const genres = schema.enum("genres", [ export const genres = schema.enum("genres", [
"action", "action",
"adventure", "adventure",
@ -51,17 +56,20 @@ export const shows = schema.table(
genres: genres().array().notNull(), genres: genres().array().notNull(),
rating: smallint(), rating: smallint(),
status: showStatus().notNull(), status: showStatus().notNull(),
startAir: date(), startAir: date({ mode: "date" }),
endAir: date(), endAir: date({ mode: "date" }),
originalLanguage: language(), originalLanguage: language(),
externalId: jsonb().notNull().default({}), externalId: externalid(),
createdAt: timestamp({ withTimezone: true }).defaultNow(), createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
nextRefresh: timestamp({ withTimezone: true }), nextRefresh: timestamp({ withTimezone: true }).notNull(),
}, },
(t) => ({ (t) => ({
ratingValid: check("ratingValid", sql`0 <= ${t.rating} && ${t.rating} <= 100`), ratingValid: check(
"ratingValid",
sql`0 <= ${t.rating} && ${t.rating} <= 100`,
),
}), }),
); );
@ -78,10 +86,10 @@ export const showTranslations = schema.table(
aliases: text().array().notNull(), aliases: text().array().notNull(),
tags: text().array().notNull(), tags: text().array().notNull(),
trailerUrl: text(), trailerUrl: text(),
poster: jsonb(), poster: image(),
thumbnail: jsonb(), thumbnail: image(),
banner: jsonb(), banner: image(),
logo: jsonb(), logo: image(),
}, },
(t) => ({ (t) => ({
pk: primaryKey({ columns: [t.pk, t.language] }), pk: primaryKey({ columns: [t.pk, t.language] }),

View File

@ -1,5 +1,22 @@
import { pgSchema, varchar } from "drizzle-orm/pg-core"; import { jsonb, pgSchema, varchar } from "drizzle-orm/pg-core";
export const schema = pgSchema("kyoo"); export const schema = pgSchema("kyoo");
export const language = () => varchar({ length: 255 }); export const language = () => varchar({ length: 255 });
export const image = () =>
jsonb().$type<{ source: string; blurhash: string }>();
export const externalid = () =>
jsonb()
.$type<
Record<
string,
{
dataId: string;
link: string | null;
}
>
>()
.notNull()
.default({});