From b94e7834be7b632f43bef36462af7f0000893e11 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Sun, 23 Aug 2026 09:51:19 +0200 Subject: [PATCH] refactor(db): add explicit string length limits to users and tasks tables --- db/schema.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/db/schema.ts b/db/schema.ts index 95f832d..e23da5d 100644 --- a/db/schema.ts +++ b/db/schema.ts @@ -11,6 +11,7 @@ import { text, timestamp, uuid, + varchar, } from "drizzle-orm/pg-core"; // ========================================== @@ -50,12 +51,12 @@ export const userRoleEnum = pgEnum("user_role", ["admin", "member", "guest"]); */ export const usersTable = pgTable("users", { id: uuid("id").defaultRandom().primaryKey(), - email: text("email").notNull().unique(), + email: varchar("email", { length: 255 }).notNull().unique(), password: text("password").notNull(), - firstName: text("first_name").notNull(), - lastName: text("last_name").notNull(), - role: text("role").default("member").notNull(), - color: text("color").default("bg-indigo-500").notNull(), + firstName: varchar("first_name", { length: 50 }).notNull(), + lastName: varchar("last_name", { length: 50 }).notNull(), + role: userRoleEnum("role").default("member").notNull(), + color: varchar("color", { length: 50 }).default("bg-indigo-500").notNull(), lastLogin: timestamp("last_login"), isOnline: boolean("is_online").default(false).notNull(), createdAt: timestamp("created_at").defaultNow().notNull(), @@ -69,8 +70,8 @@ export const tasksTable = pgTable("tasks", { userId: uuid("user_id") .notNull() .references(() => usersTable.id, { onDelete: "cascade" }), - title: text("title").notNull(), - description: text("description").notNull(), + title: varchar("title", { length: 255 }).notNull(), + description: varchar("description", { length: 2000 }).notNull(), status: taskStatusEnum("status").default("todo").notNull(), priority: taskPriorityEnum("priority").default("medium").notNull(), dueDate: timestamp("due_date").notNull(),