summaryrefslogtreecommitdiff
path: root/db/schema/tasks.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-03-25 15:55:45 +0900
committerjoonhoekim <26rote@gmail.com>2025-03-25 15:55:45 +0900
commit1a2241c40e10193c5ff7008a7b7b36cc1d855d96 (patch)
tree8a5587f10ca55b162d7e3254cb088b323a34c41b /db/schema/tasks.ts
initial commit
Diffstat (limited to 'db/schema/tasks.ts')
-rw-r--r--db/schema/tasks.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/db/schema/tasks.ts b/db/schema/tasks.ts
new file mode 100644
index 00000000..fc4000bb
--- /dev/null
+++ b/db/schema/tasks.ts
@@ -0,0 +1,46 @@
+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'))`
+ )
+ ,
+ 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<Task, "code"> & {
+ code?: string
+} \ No newline at end of file