work-hub-server/packages/schema/src/drizzle/tasks.ts
Nicolas HOARAU f11c306ac6
All checks were successful
ci / ci (22) (push) Successful in 11m57s
feat: add type checking and linting improvements across the project
- Added "check-types" script to package.json for type checking in both api and web apps.
- Updated ESLint configuration to use a shared tooling package for consistent linting rules.
- Refactored TypeScript configurations to extend from shared tooling configurations.
- Improved code formatting and consistency in various files, including Vue components and TypeScript files.
- Introduced CI workflow for automated linting, formatting checks, and type checking on push and pull request events.
- Cleaned up unnecessary dependencies and updated existing ones for better performance and maintainability.
2026-06-04 16:33:06 +04:00

30 lines
1.2 KiB
TypeScript

import { pgTable, uuid, text, integer, timestamp, check } from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm";
import { TASK_STATUSES, PRIORITIES } from "./enums";
import { projects } from "./projects";
const taskStatusValues = TASK_STATUSES.map((s) => `'${s}'`).join(", ");
const priorityValues = PRIORITIES.map((p) => `'${p}'`).join(", ");
export const tasks = pgTable(
"tasks",
{
id: uuid("id").primaryKey().defaultRandom(),
projectId: uuid("project_id")
.notNull()
.references(() => projects.id, { onDelete: "cascade" }),
title: text("title").notNull(),
description: text("description"),
status: text("status").notNull().default("todo"),
priority: text("priority").notNull().default("medium"),
sortOrder: integer("sort_order").notNull().default(0),
dueDate: timestamp("due_date", { mode: "string" }),
createdAt: timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { mode: "string" }).notNull().defaultNow(),
},
(table) => [
check("task_status_check", sql`${table.status} IN (${sql.raw(taskStatusValues)})`),
check("task_priority_check", sql`${table.priority} IN (${sql.raw(priorityValues)})`),
],
);