Files
task-manager/shared/schema.ts
T
paul-nothaft 52f29fa101 Add a system for organizing tasks with customizable color-coded labels
Implement a label system with API endpoints for CRUD operations on labels and tasks, including schema definitions for labels and tasks with label associations.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/XrG8SoT
2025-09-11 11:54:28 +00:00

51 lines
1.8 KiB
TypeScript

import { sql } from "drizzle-orm";
import { pgTable, text, varchar, timestamp, integer, boolean } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod";
export const users = pgTable("users", {
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
username: text("username").notNull().unique(),
password: text("password").notNull(),
});
export const labels = pgTable("labels", {
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
name: text("name").notNull(),
color: text("color").notNull(),
});
export const tasks = pgTable("tasks", {
id: varchar("id").primaryKey().default(sql`gen_random_uuid()`),
title: text("title").notNull(),
description: text("description"),
status: text("status").notNull().default("todo"), // 'todo' | 'inProgress' | 'done'
priority: text("priority").notNull().default("medium"), // 'low' | 'medium' | 'high'
dueDate: timestamp("due_date"),
timeTracked: integer("time_tracked").notNull().default(0), // in minutes
isTracking: boolean("is_tracking").notNull().default(false),
projectId: text("project_id"),
notes: text("notes"),
labelId: varchar("label_id").references(() => labels.id),
});
export const insertUserSchema = createInsertSchema(users).pick({
username: true,
password: true,
});
export const insertLabelSchema = createInsertSchema(labels).omit({
id: true,
});
export const insertTaskSchema = createInsertSchema(tasks).omit({
id: true,
});
export type InsertUser = z.infer<typeof insertUserSchema>;
export type User = typeof users.$inferSelect;
export type InsertLabel = z.infer<typeof insertLabelSchema>;
export type Label = typeof labels.$inferSelect;
export type InsertTask = z.infer<typeof insertTaskSchema>;
export type Task = typeof tasks.$inferSelect;