23 lines
716 B
TypeScript
23 lines
716 B
TypeScript
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()),
|
|
});
|