mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 20:24:27 -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 { drizzle } from "drizzle-orm/node-postgres";
|
||||||
import * as entries from "./schema/entries";
|
import * as schema from "./schema";
|
||||||
import * as seasons from "./schema/seasons";
|
|
||||||
import * as shows from "./schema/shows";
|
|
||||||
import * as videos from "./schema/videos";
|
|
||||||
|
|
||||||
export const db = drizzle({
|
export const db = drizzle({
|
||||||
schema: {
|
schema,
|
||||||
...entries,
|
|
||||||
...shows,
|
|
||||||
...seasons,
|
|
||||||
...videos,
|
|
||||||
},
|
|
||||||
connection: {
|
connection: {
|
||||||
user: process.env.POSTGRES_USER ?? "kyoo",
|
user: process.env.POSTGRES_USER ?? "kyoo",
|
||||||
password: process.env.POSTGRES_PASSWORD ?? "password",
|
password: process.env.POSTGRES_PASSWORD ?? "password",
|
||||||
|
@ -23,7 +23,7 @@ export const entryType = schema.enum("entry_type", [
|
|||||||
"extra",
|
"extra",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const entryid = () =>
|
export const entry_extid = () =>
|
||||||
jsonb()
|
jsonb()
|
||||||
.$type<
|
.$type<
|
||||||
Record<
|
Record<
|
||||||
@ -60,7 +60,7 @@ export const entries = schema.table(
|
|||||||
runtime: integer(),
|
runtime: integer(),
|
||||||
thumbnails: image(),
|
thumbnails: image(),
|
||||||
|
|
||||||
externalId: entryid(),
|
externalId: entry_extid(),
|
||||||
|
|
||||||
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
|
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
|
||||||
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
|
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
|
||||||
@ -71,8 +71,8 @@ export const entries = schema.table(
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
export const entriesTranslation = schema.table(
|
export const entryTranslations = schema.table(
|
||||||
"entries_translation",
|
"entry_translations",
|
||||||
{
|
{
|
||||||
pk: integer()
|
pk: integer()
|
||||||
.notNull()
|
.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 { image, language, schema } from "./utils";
|
||||||
import { shows } from "./shows";
|
import { shows } from "./shows";
|
||||||
|
|
||||||
export const entryid = () =>
|
export const season_extid = () =>
|
||||||
jsonb()
|
jsonb()
|
||||||
.$type<
|
.$type<
|
||||||
Record<
|
Record<
|
||||||
@ -38,7 +38,7 @@ export const seasons = schema.table(
|
|||||||
startAir: date(),
|
startAir: date(),
|
||||||
endAir: date(),
|
endAir: date(),
|
||||||
|
|
||||||
externalId: entryid(),
|
externalId: season_extid(),
|
||||||
|
|
||||||
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
|
createdAt: timestamp({ withTimezone: true, mode: "string" }).defaultNow(),
|
||||||
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
|
nextRefresh: timestamp({ withTimezone: true, mode: "string" }),
|
||||||
@ -47,7 +47,7 @@ export const seasons = schema.table(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const seasonTranslation = schema.table(
|
export const seasonTranslation = schema.table(
|
||||||
"season_translation",
|
"season_translations",
|
||||||
{
|
{
|
||||||
pk: integer()
|
pk: integer()
|
||||||
.notNull()
|
.notNull()
|
||||||
|
@ -15,14 +15,16 @@ export const videos = schema.table(
|
|||||||
{
|
{
|
||||||
pk: integer().primaryKey().generatedAlwaysAsIdentity(),
|
pk: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||||
id: uuid().notNull().unique().defaultRandom(),
|
id: uuid().notNull().unique().defaultRandom(),
|
||||||
slug: varchar({ length: 255 }).notNull().unique(),
|
slug: varchar({ length: 255 }).unique(),
|
||||||
path: text().notNull().unique(),
|
path: text().notNull().unique(),
|
||||||
rendering: text().notNull(),
|
rendering: text().notNull(),
|
||||||
part: integer(),
|
part: integer(),
|
||||||
version: integer().notNull().default(1),
|
version: integer().notNull().default(1),
|
||||||
guess: jsonb().notNull().default({}),
|
guess: jsonb().notNull().default({}),
|
||||||
|
|
||||||
createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
|
createdAt: timestamp({ withTimezone: true, mode: "string" })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
},
|
},
|
||||||
(t) => [
|
(t) => [
|
||||||
check("part_pos", sql`${t.part} >= 0`),
|
check("part_pos", sql`${t.part} >= 0`),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user