feat: Add user tracking to project tasks and notes
- Implemented user tracking columns in project_tasks and notes tables. - Added created_by and assigned_to fields to project_tasks. - Introduced created_by field and is_system flag in notes. - Updated API endpoints to handle user tracking during task and note creation. - Enhanced database initialization to include new columns and indexes. - Created utility functions to fetch users for task assignment. - Updated front-end components to display user information for tasks and notes. - Added tests for project-tasks API endpoints to verify functionality.
This commit is contained in:
@@ -196,11 +196,72 @@ export default function initializeDatabase() {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Add foreign key indexes for performance
|
||||
// Migration: Add user tracking columns to project_tasks table
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE INDEX IF NOT EXISTS idx_projects_created_by ON projects(created_by);
|
||||
CREATE INDEX IF NOT EXISTS idx_projects_assigned_to ON projects(assigned_to);
|
||||
ALTER TABLE project_tasks ADD COLUMN created_by TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE project_tasks ADD COLUMN assigned_to TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE project_tasks ADD COLUMN created_at TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE project_tasks ADD COLUMN updated_at TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Create indexes for project_tasks user tracking
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE INDEX IF NOT EXISTS idx_project_tasks_created_by ON project_tasks(created_by);
|
||||
CREATE INDEX IF NOT EXISTS idx_project_tasks_assigned_to ON project_tasks(assigned_to);
|
||||
`);
|
||||
} catch (e) {
|
||||
// Index already exists, ignore error
|
||||
}
|
||||
|
||||
// Migration: Add user tracking columns to notes table
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE notes ADD COLUMN created_by TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE notes ADD COLUMN is_system INTEGER DEFAULT 0;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Create indexes for notes user tracking
|
||||
try {
|
||||
db.exec(`
|
||||
CREATE INDEX IF NOT EXISTS idx_notes_created_by ON notes(created_by);
|
||||
CREATE INDEX IF NOT EXISTS idx_notes_project_id ON notes(project_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notes_task_id ON notes(task_id);
|
||||
`);
|
||||
} catch (e) {
|
||||
// Index already exists, ignore error
|
||||
|
||||
Reference in New Issue
Block a user