mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add video schema
This commit is contained in:
parent
e7ed36caff
commit
6f71b98209
@ -1,11 +1,13 @@
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import * as entries from "./schema/entries";
|
||||
import * as shows from "./schema/shows";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import * as videos from "./schema/videos";
|
||||
|
||||
export const db = drizzle({
|
||||
schema: {
|
||||
...entries,
|
||||
...shows,
|
||||
...videos,
|
||||
},
|
||||
connection: {
|
||||
user: process.env.POSTGRES_USER ?? "kyoo",
|
||||
|
22
api/src/db/schema/videos.ts
Normal file
22
api/src/db/schema/videos.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { check, integer, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { schema } from "./utils";
|
||||
|
||||
export const videos = schema.table(
|
||||
"videos",
|
||||
{
|
||||
pk: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||
id: uuid().notNull().unique().defaultRandom(),
|
||||
path: text().notNull().unique(),
|
||||
rendering: integer(),
|
||||
part: integer(),
|
||||
version: integer(),
|
||||
|
||||
createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(t) => ({
|
||||
ratingValid: check("renderingPos", sql`0 <= ${t.rendering}`),
|
||||
partValid: check("partPos", sql`0 <= ${t.part}`),
|
||||
versionValid: check("versionPos", sql`0 <= ${t.version}`),
|
||||
}),
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user