Implement many-to-many TODO user assignments
- Create todo_users junction table for many-to-many relationship - Add migration to create todo_users table and migrate existing data - Update validators to accept assignedUserIds array instead of assignedTo - Update todo service to handle multiple user assignments - Fetch and return assigned users with each TODO 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -149,7 +149,6 @@ export const todos = pgTable('todos', {
|
||||
description: text('description'),
|
||||
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }), // todo môže patriť projektu
|
||||
companyId: uuid('company_id').references(() => companies.id, { onDelete: 'cascade' }), // alebo firme
|
||||
assignedTo: uuid('assigned_to').references(() => users.id, { onDelete: 'set null' }), // komu je priradené
|
||||
status: todoStatusEnum('status').default('pending').notNull(),
|
||||
priority: todoPriorityEnum('priority').default('medium').notNull(),
|
||||
dueDate: timestamp('due_date'),
|
||||
@@ -159,6 +158,17 @@ export const todos = pgTable('todos', {
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||
});
|
||||
|
||||
// Todo Users - many-to-many medzi todos a users (priradení používatelia)
|
||||
export const todoUsers = pgTable('todo_users', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
todoId: uuid('todo_id').references(() => todos.id, { onDelete: 'cascade' }).notNull(),
|
||||
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
|
||||
assignedBy: uuid('assigned_by').references(() => users.id, { onDelete: 'set null' }), // kto pridal používateľa k todo
|
||||
assignedAt: timestamp('assigned_at').defaultNow().notNull(),
|
||||
}, (table) => ({
|
||||
todoUserUnique: unique('todo_user_unique').on(table.todoId, table.userId),
|
||||
}));
|
||||
|
||||
// Notes table - poznámky
|
||||
export const notes = pgTable('notes', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
||||
Reference in New Issue
Block a user