- 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.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import Database from "better-sqlite3";
|
|
|
|
const db = new Database("./data/database.sqlite");
|
|
|
|
console.log("Adding missing columns to project_tasks table...\n");
|
|
|
|
try {
|
|
console.log("Adding created_at column...");
|
|
db.exec(`ALTER TABLE project_tasks ADD COLUMN created_at TEXT;`);
|
|
console.log("✓ created_at column added");
|
|
} catch (e) {
|
|
console.log("created_at column already exists or error:", e.message);
|
|
}
|
|
|
|
try {
|
|
console.log("Adding updated_at column...");
|
|
db.exec(`ALTER TABLE project_tasks ADD COLUMN updated_at TEXT;`);
|
|
console.log("✓ updated_at column added");
|
|
} catch (e) {
|
|
console.log("updated_at column already exists or error:", e.message);
|
|
}
|
|
|
|
console.log("\nVerifying columns were added...");
|
|
const schema = db.prepare("PRAGMA table_info(project_tasks)").all();
|
|
const hasCreatedAt = schema.some((col) => col.name === "created_at");
|
|
const hasUpdatedAt = schema.some((col) => col.name === "updated_at");
|
|
|
|
console.log("created_at exists:", hasCreatedAt);
|
|
console.log("updated_at exists:", hasUpdatedAt);
|
|
|
|
if (hasCreatedAt && hasUpdatedAt) {
|
|
console.log("\n✅ All columns are now present!");
|
|
} else {
|
|
console.log("\n❌ Some columns are still missing");
|
|
}
|
|
|
|
db.close();
|