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", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
email: text("email").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
id: integer().primaryKey({ autoIncrement: true }),
name: text().notNull(),
email: text().notNull().unique(),
});
export const posts = sqliteTable("posts", {
id: integer("id").primaryKey({ autoIncrement: true }),
title: text("title").notNull(),
content: text("content"),
authorId: integer("author_id")
.notNull()
.references(() => users.id),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
});
export const files = sqliteTable("files", {
id: integer().primaryKey({ autoIncrement: true }),
ownerId: integer().notNull(),
path: text().notNull(),
}, (table) => [
foreignKey({
columns: [table.ownerId],
foreignColumns: [users.id],
}),
]);