feat: Implement file upload and management system with database integration

This commit is contained in:
2025-07-30 11:37:25 +02:00
parent 07b4af5f24
commit 639a7b7eab
9 changed files with 778 additions and 0 deletions

View File

@@ -341,4 +341,26 @@ export default function initializeDatabase() {
} catch (e) {
console.warn("Migration warning:", e.message);
}
// Generic file attachments table
db.exec(`
CREATE TABLE IF NOT EXISTS file_attachments (
file_id INTEGER PRIMARY KEY AUTOINCREMENT,
entity_type TEXT NOT NULL CHECK(entity_type IN ('contract', 'project', 'task')),
entity_id INTEGER NOT NULL,
original_filename TEXT NOT NULL,
stored_filename TEXT NOT NULL,
file_path TEXT NOT NULL,
file_size INTEGER,
mime_type TEXT,
description TEXT,
uploaded_by TEXT,
upload_date TEXT DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (uploaded_by) REFERENCES users(id)
);
-- Create indexes for file attachments
CREATE INDEX IF NOT EXISTS idx_file_attachments_entity ON file_attachments(entity_type, entity_id);
CREATE INDEX IF NOT EXISTS idx_file_attachments_uploaded_by ON file_attachments(uploaded_by);
`);
}