mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Cleanup schemas
This commit is contained in:
parent
b47c38ca76
commit
b63391d744
@ -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",
|
||||
|
@ -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()
|
||||
|
4
api/src/db/schema/index.ts
Normal file
4
api/src/db/schema/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export * from "./entries";
|
||||
export * from "./seasons";
|
||||
export * from "./shows";
|
||||
export * from "./videos";
|
@ -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()
|
||||
|
@ -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`),
|
||||
|
Loading…
x
Reference in New Issue
Block a user