-- Citizen System - Word Processor Documents
-- Tabela przechowująca dokumenty utworzone w Word Processor

CREATE TABLE IF NOT EXISTS word_documents (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    html_content LONGTEXT NOT NULL,
    author VARCHAR(100) NOT NULL,
    share_code VARCHAR(10) UNIQUE,
    is_shared BOOLEAN DEFAULT FALSE,
    word_count INT DEFAULT 0,
    char_count INT DEFAULT 0,
    template_type VARCHAR(50),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_author (author),
    INDEX idx_share_code (share_code),
    INDEX idx_created (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
