feat: add categories and favorites schemas with integrations
Added `categories` and `favorites` database schemas with full type inference support. Integrated categories into `content` schema with new properties (`categoryId`, `slug`, `views`, and `usageCount`). Updated `tags` schema to include `userId` with reference to `users`. Exported new schemas in index for broader usage.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
uuid,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { categories } from "./categories";
|
||||
import { tags } from "./tags";
|
||||
import { users } from "./users";
|
||||
|
||||
@@ -21,10 +22,16 @@ export const contents = pgTable(
|
||||
.notNull()
|
||||
.references(() => users.uuid, { onDelete: "cascade" }),
|
||||
type: contentType("type").notNull(),
|
||||
categoryId: uuid("category_id").references(() => categories.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
title: varchar("title", { length: 255 }).notNull(),
|
||||
slug: varchar("slug", { length: 255 }).notNull().unique(),
|
||||
storageKey: varchar("storage_key", { length: 512 }).notNull().unique(), // Clé interne S3
|
||||
mimeType: varchar("mime_type", { length: 128 }).notNull(), // Pour le Content-Type HTTP
|
||||
fileSize: integer("file_size").notNull(), // Taille en octets
|
||||
views: integer("views").notNull().default(0),
|
||||
usageCount: integer("usage_count").notNull().default(0),
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
|
||||
Reference in New Issue
Block a user