import db from "./src/lib/db.js"; // Migration to add docx_templates table const migration = () => { console.log("Running migration: add-docx-templates-table"); try { db.exec(` -- Table: docx_templates CREATE TABLE IF NOT EXISTS docx_templates ( template_id INTEGER PRIMARY KEY AUTOINCREMENT, template_name TEXT NOT NULL, description TEXT, original_filename TEXT NOT NULL, stored_filename TEXT NOT NULL, file_path TEXT NOT NULL, file_size INTEGER NOT NULL, mime_type TEXT NOT NULL, is_active INTEGER DEFAULT 1, created_at TEXT DEFAULT CURRENT_TIMESTAMP, created_by TEXT, updated_at TEXT DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (created_by) REFERENCES users(id) ); -- Indexes for templates CREATE INDEX IF NOT EXISTS idx_docx_templates_active ON docx_templates(is_active); CREATE INDEX IF NOT EXISTS idx_docx_templates_created_by ON docx_templates(created_by); `); console.log("Migration completed successfully"); } catch (error) { console.error("Migration failed:", error); throw error; } }; migration();