ALTER TABLE pages
    ADD COLUMN meta_title VARCHAR(255) DEFAULT NULL AFTER body,
    ADD COLUMN meta_description VARCHAR(500) DEFAULT NULL AFTER meta_title;

CREATE TABLE IF NOT EXISTS page_translations (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    page_id INT UNSIGNED NOT NULL,
    lang_code VARCHAR(5) NOT NULL,
    title VARCHAR(255) NOT NULL,
    slug VARCHAR(280) NOT NULL,
    body TEXT DEFAULT NULL,
    meta_title VARCHAR(255) DEFAULT NULL,
    meta_description VARCHAR(500) DEFAULT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY idx_page_lang (page_id, lang_code),
    UNIQUE KEY idx_lang_slug (lang_code, slug),
    INDEX idx_page_id (page_id),
    CONSTRAINT fk_pt_page FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
