feat: update schema

This commit is contained in:
konrad-enlaye
2025-12-04 16:26:48 -05:00
parent 1e2148cdae
commit e334c0b6ad

View File

@@ -1,22 +1,18 @@
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; import { sqliteTable, text, integer, foreignKey } from "drizzle-orm/sqlite-core";
export const users = sqliteTable("users", { export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true }), id: integer().primaryKey({ autoIncrement: true }),
name: text("name").notNull(), name: text().notNull(),
email: text("email").notNull().unique(), email: text().notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
}); });
export const posts = sqliteTable("posts", { export const files = sqliteTable("files", {
id: integer("id").primaryKey({ autoIncrement: true }), id: integer().primaryKey({ autoIncrement: true }),
title: text("title").notNull(), ownerId: integer().notNull(),
content: text("content"), path: text().notNull(),
authorId: integer("author_id") }, (table) => [
.notNull() foreignKey({
.references(() => users.id), columns: [table.ownerId],
createdAt: integer("created_at", { mode: "timestamp" }) foreignColumns: [users.id],
.notNull() }),
.$defaultFn(() => new Date()), ]);
});