import { pgTable, text, integer, boolean, timestamp, uuid } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { z } from "zod/v4"; import { projectsTable } from "./projects"; export const tasksTable = pgTable("tasks", { id: integer("id").primaryKey().generatedAlwaysAsIdentity(), projectId: integer("project_id").notNull().references(() => projectsTable.id, { onDelete: "cascade" }), title: text("title").notNull(), done: boolean("done").notNull().default(false), dueDate: text("due_date"), 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 insertTaskSchema = createInsertSchema(tasksTable).pick({ projectId: true, title: true, done: true, dueDate: true, }); export type InsertTask = z.infer; export type Task = typeof tasksTable.$inferSelect;