import { pgTable, uuid, text, timestamp, check } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm"; import { PROJECT_STATUSES } from "./enums"; const projectStatusValues = PROJECT_STATUSES.map((s) => `'${s}'`).join(", "); export const projects = pgTable( "projects", { id: uuid("id").primaryKey().defaultRandom(), name: text("name").notNull(), description: text("description"), status: text("status").notNull().default("active"), createdAt: timestamp("created_at", { mode: "string" }) .notNull() .defaultNow(), updatedAt: timestamp("updated_at", { mode: "string" }) .notNull() .defaultNow(), }, (table) => [ check( "project_status_check", sql`${table.status} IN (${sql.raw(projectStatusValues)})`, ), ], );