gemma: generate apps/api/src/db/schema.ts

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 04:25:16 +02:00
parent 58a97cb9a9
commit 7a5409b98c

35
apps/api/src/db/schema.ts Normal file
View File

@ -0,0 +1,35 @@
import { pgTable, text, timestamp, boolean, uuid } from "drizzle-orm/pg-core"
export const users = pgTable("users", {
id: uuid("id").primaryKey().defaultRandom(),
email: text("email").notNull().unique(),
name: text("name").notNull(),
role: text("role").notNull(),
passwordHash: text("password_hash").notNull(),
createdAt: timestamp("created_at").notNull().defaultNow()
})
export const customers = pgTable("customers", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name").notNull(),
active: boolean("active").notNull().default(true),
createdAt: timestamp("created_at").notNull().defaultNow()
})
export const projects = pgTable("projects", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name").notNull(),
customerId: uuid("customer_id").notNull().references(() => customers.id, { onDelete: "cascade" }),
active: boolean("active").notNull().default(true),
createdAt: timestamp("created_at").notNull().defaultNow()
})
export const timeEntries = pgTable("time_entries", {
id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
projectId: uuid("project_id").references(() => projects.id, { onDelete: "cascade" }),
description: text("description").notNull(),
startTime: timestamp("start_time").notNull(),
endTime: timestamp("end_time"),
createdAt: timestamp("created_at").notNull().defaultNow()
})