feat: Enhance project task management with expandable notes and descriptions, and add date_started column for task tracking
This commit is contained in:
@@ -126,7 +126,6 @@ export default function initializeDatabase() {
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Migration: Copy data from geo_info to coordinates and drop geo_info
|
||||
try {
|
||||
db.exec(`
|
||||
@@ -138,4 +137,13 @@ export default function initializeDatabase() {
|
||||
} catch (e) {
|
||||
// Column migration already done or geo_info doesn't exist, ignore error
|
||||
}
|
||||
|
||||
// Migration: Add date_started column to project_tasks table
|
||||
try {
|
||||
db.exec(`
|
||||
ALTER TABLE project_tasks ADD COLUMN date_started TEXT;
|
||||
`);
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,35 @@ export function createProjectTask(data) {
|
||||
|
||||
// Update project task status
|
||||
export function updateProjectTaskStatus(taskId, status) {
|
||||
const stmt = db.prepare(`
|
||||
UPDATE project_tasks
|
||||
SET status = ?
|
||||
WHERE id = ?
|
||||
`);
|
||||
return stmt.run(status, taskId);
|
||||
// First get the current status to check if we're transitioning from pending to in_progress
|
||||
const getCurrentStatus = db.prepare(
|
||||
"SELECT status FROM project_tasks WHERE id = ?"
|
||||
);
|
||||
const currentTask = getCurrentStatus.get(taskId);
|
||||
|
||||
let stmt;
|
||||
|
||||
if (
|
||||
currentTask &&
|
||||
currentTask.status === "pending" &&
|
||||
status === "in_progress"
|
||||
) {
|
||||
// Starting a task - set date_started
|
||||
stmt = db.prepare(`
|
||||
UPDATE project_tasks
|
||||
SET status = ?, date_started = CURRENT_TIMESTAMP
|
||||
WHERE id = ?
|
||||
`);
|
||||
return stmt.run(status, taskId);
|
||||
} else {
|
||||
// Just updating status without changing date_started
|
||||
stmt = db.prepare(`
|
||||
UPDATE project_tasks
|
||||
SET status = ?
|
||||
WHERE id = ?
|
||||
`);
|
||||
return stmt.run(status, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete a project task
|
||||
|
||||
Reference in New Issue
Block a user