import { integer, pgTable, boolean, timestamp, varchar, primaryKey } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm" import { generateId } from "@/lib/id" export const tasks = pgTable("tasks", { id: varchar("id", { length: 30 }) .$defaultFn(() => generateId()) .primaryKey(), code: varchar("code", { length: 128 }) .notNull() .unique() // .default( // sql`concat('TASK-', to_char(nextval('tasks_code_seq'), 'FM0000'))` // ) // 0429 db 마이그레이션 관련 수정 , title: varchar("title", { length: 128 }), status: varchar("status", { length: 30, enum: ["todo", "in-progress", "done", "canceled"], }) .notNull() .default("todo"), label: varchar("label", { length: 30, enum: ["bug", "feature", "enhancement", "documentation"], }) .notNull() .default("bug"), priority: varchar("priority", { length: 30, enum: ["low", "medium", "high"], }) .notNull() .default("low"), archived: boolean("archived").notNull().default(false), createdAt: timestamp("created_at").defaultNow().notNull(), updatedAt: timestamp("updated_at") .default(sql`current_timestamp`) .$onUpdate(() => new Date()), }) export type Task = typeof tasks.$inferSelect export type NewTask = Omit & { code?: string }