feat: setup drizzle

This commit is contained in:
konrad-enlaye
2025-12-03 11:11:07 -05:00
parent 4172af8b4f
commit 1e2148cdae
7 changed files with 1259 additions and 2 deletions

22
src/db/schema.ts Normal file
View File

@@ -0,0 +1,22 @@
import { sqliteTable, text, integer } 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()),
});
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()),
});