From d7fd62d6b4ce92fd4018459ae7b8df5d1347e714 Mon Sep 17 00:00:00 2001 From: seaznCode Date: Wed, 14 Jan 2026 16:57:16 +0100 Subject: [PATCH] feat: update user_documents table to allow nullable object_storage_id and add signatureBase64 column --- database/createDb.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/database/createDb.js b/database/createDb.js index 3b15864..ef6fb02 100644 --- a/database/createDb.js +++ b/database/createDb.js @@ -271,7 +271,8 @@ async function createDatabase() { user_id INT NOT NULL, document_type ENUM('personal_id', 'company_id', 'signature', 'contract', 'other') NOT NULL, contract_type ENUM('contract','gdpr') NOT NULL DEFAULT 'contract', - object_storage_id VARCHAR(255) UNIQUE NOT NULL, + object_storage_id VARCHAR(255) UNIQUE NULL, + signatureBase64 LONGTEXT NULL, original_filename VARCHAR(255), file_size INT, mime_type VARCHAR(100), @@ -292,6 +293,14 @@ async function createDatabase() { await connection.query(` CREATE INDEX IF NOT EXISTS idx_user_contract_type ON user_documents (user_id, contract_type); `); + await connection.query(` + ALTER TABLE user_documents + MODIFY COLUMN object_storage_id VARCHAR(255) NULL; + `); + await connection.query(` + ALTER TABLE user_documents + ADD COLUMN IF NOT EXISTS signatureBase64 LONGTEXT NULL AFTER object_storage_id; + `); console.log('✅ User documents table created/verified'); // 8c. document_templates table: Stores template metadata and object storage keys