chore: update pnpm workspace with TypeScript and Zod versions; enhance turbo.json task formatting
This commit is contained in:
33
packages/db/src/schema.ts
Normal file
33
packages/db/src/schema.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { pgTable, serial, varchar, integer, pgEnum, primaryKey } from 'drizzle-orm/pg-core';
|
||||
import { relations } from 'drizzle-orm';
|
||||
|
||||
//#region Enums
|
||||
export const BookTypeEnum = pgEnum("book_type", ["novel", "fanfic"]);
|
||||
export const LeadingGenderEnum = pgEnum("leading_gender", ["male", "female"]);
|
||||
//#endregion Enums
|
||||
|
||||
//#region Genre
|
||||
export const Genre = pgTable("genres", {
|
||||
id: serial("id").primaryKey(),
|
||||
name: varchar("name").notNull(),
|
||||
description: varchar("description").notNull(),
|
||||
});
|
||||
export const GenreTranslation = pgTable("genre_translations", {
|
||||
id: integer("id"),
|
||||
locale: varchar("locale").notNull(),
|
||||
name: varchar("name").notNull(),
|
||||
description: varchar("description"),
|
||||
}, (t) => ([
|
||||
primaryKey({ columns: [t.id, t.locale] }),
|
||||
]));
|
||||
// Relations
|
||||
export const GenreRelations = relations(Genre, ({ many }) => ({
|
||||
translations: many(GenreTranslation)
|
||||
}));
|
||||
export const GenreTranslationRelations = relations(GenreTranslation, ({ one }) => ({
|
||||
genre: one(Genre, {
|
||||
fields: [GenreTranslation.id],
|
||||
references: [Genre.id],
|
||||
}),
|
||||
}));
|
||||
//#endregion Genre
|
Reference in New Issue
Block a user