35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { sql } from "drizzle-orm";
|
|
import { boolean, index, jsonb, smallint, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
import { appSchema } from "./_schema";
|
|
|
|
export const todos = appSchema.table(
|
|
"todos",
|
|
{
|
|
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
|
title: text("title").notNull(),
|
|
description: text("description"),
|
|
status: text("status").notNull().default("inbox"),
|
|
priority: smallint("priority"),
|
|
dueAt: timestamp("due_at", { withTimezone: true }),
|
|
tags: text("tags").array().notNull().default(sql`'{}'::text[]`),
|
|
projectId: uuid("project_id"),
|
|
checklist: jsonb("checklist").notNull().default(sql`'[]'::jsonb`),
|
|
energy: text("energy"),
|
|
context: text("context"),
|
|
recurrence: text("recurrence"),
|
|
ticketUrl: text("ticket_url"),
|
|
verificationSteps: text("verification_steps").array().notNull().default(sql`'{}'::text[]`),
|
|
aiEnriched: boolean("ai_enriched").notNull().default(false),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
},
|
|
(t) => ({
|
|
statusIdx: index("todos_status_idx").on(t.status),
|
|
dueAtIdx: index("todos_due_at_idx").on(t.dueAt),
|
|
tagsGin: index("todos_tags_gin").using("gin", t.tags),
|
|
}),
|
|
);
|
|
|
|
export type TodoRow = typeof todos.$inferSelect;
|
|
export type TodoInsert = typeof todos.$inferInsert;
|