feat: update user_documents table to allow nullable object_storage_id and add signatureBase64 column

This commit is contained in:
seaznCode 2026-01-14 16:57:16 +01:00
parent edeacea8ea
commit d7fd62d6b4

View File

@ -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