- 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.
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
import Database from "better-sqlite3";
|
|
|
|
const db = new Database("./data/database.sqlite");
|
|
|
|
console.log("Project Tasks table columns:");
|
|
const projectTasksSchema = db.prepare("PRAGMA table_info(project_tasks)").all();
|
|
projectTasksSchema.forEach((col) => {
|
|
console.log(
|
|
`${col.name}: ${col.type} (${col.notnull ? "NOT NULL" : "NULL"})`
|
|
);
|
|
});
|
|
|
|
console.log("\nChecking if created_at and updated_at columns exist...");
|
|
const hasCreatedAt = projectTasksSchema.some(
|
|
(col) => col.name === "created_at"
|
|
);
|
|
const hasUpdatedAt = projectTasksSchema.some(
|
|
(col) => col.name === "updated_at"
|
|
);
|
|
console.log("created_at exists:", hasCreatedAt);
|
|
console.log("updated_at exists:", hasUpdatedAt);
|
|
|
|
// Let's try a simple insert to see what happens
|
|
console.log("\nTesting manual insert...");
|
|
try {
|
|
const result = db
|
|
.prepare(
|
|
`
|
|
INSERT INTO project_tasks (
|
|
project_id, task_template_id, status, priority,
|
|
created_by, assigned_to, created_at, updated_at
|
|
)
|
|
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
|
`
|
|
)
|
|
.run(1, 1, "pending", "normal", "test-user", "test-user");
|
|
|
|
console.log("Insert successful, ID:", result.lastInsertRowid);
|
|
|
|
// Clean up
|
|
db.prepare("DELETE FROM project_tasks WHERE id = ?").run(
|
|
result.lastInsertRowid
|
|
);
|
|
console.log("Test record cleaned up");
|
|
} catch (error) {
|
|
console.error("Insert failed:", error.message);
|
|
}
|
|
|
|
db.close();
|