Cleanup schemas

This commit is contained in:
Zoe Roux 2024-11-24 23:26:20 +01:00
parent b47c38ca76
commit b63391d744
No known key found for this signature in database
5 changed files with 17 additions and 19 deletions

View File

@ -1,16 +1,8 @@
import { drizzle } from "drizzle-orm/node-postgres";
import * as entries from "./schema/entries";
import * as seasons from "./schema/seasons";
import * as shows from "./schema/shows";
import * as videos from "./schema/videos";
import * as schema from "./schema";
export const db = drizzle({
schema: {
...entries,
...shows,
...seasons,
...videos,
},
schema,
connection: {
user: process.env.POSTGRES_USER ?? "kyoo",
password: process.env.POSTGRES_PASSWORD ?? "password",

View File

@ -23,7 +23,7 @@ export const entryType = schema.enum("entry_type", [
"extra",
]);
export const entryid = () =>
export const entry_extid = () =>
jsonb()
.$type<
Record<
@ -60,7 +60,7 @@ export const entries = schema.table(
runtime: integer(),
thumbnails: image(),
externalId: entryid(),
externalId: entry_extid(),
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
@ -71,8 +71,8 @@ export const entries = schema.table(
],
);
export const entriesTranslation = schema.table(
"entries_translation",
export const entryTranslations = schema.table(
"entry_translations",
{
pk: integer()
.notNull()

View File

@ -0,0 +1,4 @@
export * from "./entries";
export * from "./seasons";
export * from "./shows";
export * from "./videos";

View File

@ -12,7 +12,7 @@ import {
import { image, language, schema } from "./utils";
import { shows } from "./shows";
export const entryid = () =>
export const season_extid = () =>
jsonb()
.$type<
Record<
@ -38,7 +38,7 @@ export const seasons = schema.table(
startAir: date(),
endAir: date(),
externalId: entryid(),
externalId: season_extid(),
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
@ -47,7 +47,7 @@ export const seasons = schema.table(
);
export const seasonTranslation = schema.table(
"season_translation",
"season_translations",
{
pk: integer()
.notNull()

View File

@ -15,14 +15,16 @@ export const videos = schema.table(
{
pk: integer().primaryKey().generatedAlwaysAsIdentity(),
id: uuid().notNull().unique().defaultRandom(),
slug: varchar({ length: 255 }).notNull().unique(),
slug: varchar({ length: 255 }).unique(),
path: text().notNull().unique(),
rendering: text().notNull(),
part: integer(),
version: integer().notNull().default(1),
guess: jsonb().notNull().default({}),
createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
createdAt: timestamp({ withTimezone: true, mode: "string" })
.notNull()
.defaultNow(),
},
(t) => [
check("part_pos", sql`${t.part} >= 0`),