feat: add task_category field to tasks with validation and update related forms
This commit is contained in:
@@ -40,7 +40,8 @@ export default function initializeDatabase() {
|
||||
task_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
max_wait_days INTEGER DEFAULT 0,
|
||||
is_standard INTEGER NOT NULL DEFAULT 0
|
||||
is_standard INTEGER NOT NULL DEFAULT 0,
|
||||
task_category TEXT CHECK(task_category IN ('design', 'construction')) NOT NULL DEFAULT 'design'
|
||||
);
|
||||
|
||||
-- Table: task_sets
|
||||
@@ -382,6 +383,22 @@ export default function initializeDatabase() {
|
||||
console.warn("Migration warning:", e.message);
|
||||
}
|
||||
|
||||
// Migration: Add task_category column to tasks table
|
||||
try {
|
||||
const tableInfo = db.prepare("PRAGMA table_info(tasks)").all();
|
||||
const hasTaskCategory = tableInfo.some(col => col.name === 'task_category');
|
||||
|
||||
if (!hasTaskCategory) {
|
||||
// Add the task_category column
|
||||
db.exec(`
|
||||
ALTER TABLE tasks ADD COLUMN task_category TEXT CHECK(task_category IN ('design', 'construction')) NOT NULL DEFAULT 'design';
|
||||
`);
|
||||
console.log("✅ Added task_category column to tasks table");
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Migration warning:", e.message);
|
||||
}
|
||||
|
||||
// Generic file attachments table
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS file_attachments (
|
||||
|
||||
Reference in New Issue
Block a user