Fix schema and add pgSchema

This commit is contained in:
Zoe Roux 2024-10-27 21:20:05 +01:00
parent e0704458ee
commit 96a8ae3de7
No known key found for this signature in database
2 changed files with 18 additions and 7 deletions

View File

@ -7,4 +7,7 @@ export default defineConfig({
dbCredentials: {
url: process.env.DATABASE_URL!,
},
migrations: {
schema: "kyoo",
},
});

View File

@ -4,17 +4,25 @@ import {
date,
integer,
jsonb,
pgEnum,
pgTable,
pgSchema,
primaryKey,
text,
timestamp,
uuid,
varchar,
} from "drizzle-orm/pg-core";
export const entryType = pgEnum("entry_type", ["unknown", "episode", "movie", "special", "extra"]);
const schema = pgSchema("kyoo");
export const entries = pgTable(
export const entryType = schema.enum("entry_type", [
"unknown",
"episode",
"movie",
"special",
"extra",
]);
export const entries = schema.table(
"entries",
{
pk: integer().primaryKey().generatedAlwaysAsIdentity(),
@ -28,7 +36,7 @@ export const entries = pgTable(
airDate: date(),
runtime: integer(),
thumbnails: jsonb(),
nextRefresh: date(),
nextRefresh: timestamp({ withTimezone: true }),
externalId: jsonb().notNull().default({}),
},
(t) => ({
@ -37,12 +45,12 @@ export const entries = pgTable(
}),
);
export const entriesTranslation = pgTable(
export const entriesTranslation = schema.table(
"entries_translation",
{
pk: integer()
.notNull()
.references(() => entries.id),
.references(() => entries.pk, { onDelete: "cascade" }),
language: varchar({ length: 255 }).notNull(),
name: text(),
description: text(),