import { pgTable, text, integer, doublePrecision, timestamp, uuid } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { z } from "zod/v4"; import { clientsTable } from "./clients"; export const projectsTable = pgTable("projects", { id: integer("id").primaryKey().generatedAlwaysAsIdentity(), title: text("title").notNull(), description: text("description"), clientId: integer("client_id").references(() => clientsTable.id, { onDelete: "set null" }), status: text("status").notNull().default("briefing"), priority: text("priority").notNull().default("medium"), budget: doublePrecision("budget"), deadline: text("deadline"), driveUrl: text("drive_url"), planUrl: text("plan_url"), 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 insertProjectSchema = createInsertSchema(projectsTable).pick({ title: true, description: true, clientId: true, status: true, priority: true, budget: true, deadline: true, driveUrl: true, planUrl: true, }); export type InsertProject = z.infer; export type Project = typeof projectsTable.$inferSelect;