import { pgTable, text, integer, doublePrecision, timestamp, uuid } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { z } from "zod/v4"; import { projectsTable } from "./projects"; export const timeEntriesTable = pgTable("time_entries", { id: integer("id").primaryKey().generatedAlwaysAsIdentity(), projectId: integer("project_id").notNull().references(() => projectsTable.id, { onDelete: "cascade" }), description: text("description"), hours: doublePrecision("hours").notNull(), date: text("date").notNull(), userId: uuid("user_id").notNull(), createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(), updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull().$onUpdate(() => new Date()), }); export const insertTimeEntrySchema = createInsertSchema(timeEntriesTable).pick({ projectId: true, description: true, hours: true, date: true, }); export type InsertTimeEntry = z.infer; export type TimeEntry = typeof timeEntriesTable.$inferSelect;