-- Kurumsal i18n: tek satır + *_en sütunları (locale satır modeline geçiş — adım 1: sütun ekleme).
USE faunamix;

-- site_pages
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'path_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN path_en VARCHAR(255) NULL DEFAULT NULL AFTER path', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN title_en VARCHAR(255) NULL DEFAULT NULL AFTER title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'short_title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN short_title_en VARCHAR(255) NULL DEFAULT NULL AFTER short_title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'excerpt_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN excerpt_en TEXT NULL AFTER excerpt', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'body_html_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN body_html_en MEDIUMTEXT NULL AFTER body_html', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'meta_title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN meta_title_en VARCHAR(255) NULL DEFAULT NULL AFTER meta_title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'meta_keywords_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN meta_keywords_en VARCHAR(512) NULL DEFAULT NULL AFTER meta_keywords', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'meta_description_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN meta_description_en TEXT NULL AFTER meta_description', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'layout_json_draft_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN layout_json_draft_en MEDIUMTEXT NULL AFTER layout_json_draft', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND COLUMN_NAME = 'layout_json_published_en');
SET @sql := IF(@c = 0, 'ALTER TABLE site_pages ADD COLUMN layout_json_published_en MEDIUMTEXT NULL AFTER layout_json_published', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @uq := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'site_pages' AND INDEX_NAME = 'uq_site_pages_path_en');
SET @sql := IF(@uq = 0, 'ALTER TABLE site_pages ADD UNIQUE KEY uq_site_pages_path_en (path_en)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- nav_menu_items
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'nav_menu_items' AND COLUMN_NAME = 'title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE nav_menu_items ADD COLUMN title_en VARCHAR(128) NULL DEFAULT NULL AFTER title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'nav_menu_items' AND COLUMN_NAME = 'url_en');
SET @sql := IF(@c = 0, 'ALTER TABLE nav_menu_items ADD COLUMN url_en VARCHAR(512) NULL DEFAULT NULL AFTER url', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- footer_menu_items
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'footer_menu_items' AND COLUMN_NAME = 'title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE footer_menu_items ADD COLUMN title_en VARCHAR(128) NULL DEFAULT NULL AFTER title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'footer_menu_items' AND COLUMN_NAME = 'url_en');
SET @sql := IF(@c = 0, 'ALTER TABLE footer_menu_items ADD COLUMN url_en VARCHAR(512) NULL DEFAULT NULL AFTER url', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- home_hero_slides
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'home_hero_slides' AND COLUMN_NAME = 'baslik_1_en');
SET @sql := IF(@c = 0, 'ALTER TABLE home_hero_slides ADD COLUMN baslik_1_en VARCHAR(255) NULL DEFAULT NULL AFTER baslik_1', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'home_hero_slides' AND COLUMN_NAME = 'baslik_2_en');
SET @sql := IF(@c = 0, 'ALTER TABLE home_hero_slides ADD COLUMN baslik_2_en VARCHAR(255) NULL DEFAULT NULL AFTER baslik_2', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'home_hero_slides' AND COLUMN_NAME = 'baslik_3_en');
SET @sql := IF(@c = 0, 'ALTER TABLE home_hero_slides ADD COLUMN baslik_3_en VARCHAR(255) NULL DEFAULT NULL AFTER baslik_3', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'home_hero_slides' AND COLUMN_NAME = 'baslik_4_en');
SET @sql := IF(@c = 0, 'ALTER TABLE home_hero_slides ADD COLUMN baslik_4_en VARCHAR(512) NULL DEFAULT NULL AFTER baslik_4', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'home_hero_slides' AND COLUMN_NAME = 'alt_text_en');
SET @sql := IF(@c = 0, 'ALTER TABLE home_hero_slides ADD COLUMN alt_text_en VARCHAR(255) NULL DEFAULT NULL AFTER alt_text', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- products
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND COLUMN_NAME = 'title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE products ADD COLUMN title_en VARCHAR(255) NULL DEFAULT NULL AFTER title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND COLUMN_NAME = 'description_en');
SET @sql := IF(@c = 0, 'ALTER TABLE products ADD COLUMN description_en TEXT NULL AFTER description', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND COLUMN_NAME = 'content_html_en');
SET @sql := IF(@c = 0, 'ALTER TABLE products ADD COLUMN content_html_en MEDIUMTEXT NULL AFTER content_html', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND COLUMN_NAME = 'slug_en');
SET @sql := IF(@c = 0, 'ALTER TABLE products ADD COLUMN slug_en VARCHAR(191) NULL DEFAULT NULL AFTER slug', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @uq := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND INDEX_NAME = 'uq_products_slug_en');
SET @sql := IF(@uq = 0, 'ALTER TABLE products ADD UNIQUE KEY uq_products_slug_en (slug_en)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- product_categories
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND COLUMN_NAME = 'title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE product_categories ADD COLUMN title_en VARCHAR(128) NULL DEFAULT NULL AFTER title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND COLUMN_NAME = 'slug_en');
SET @sql := IF(@c = 0, 'ALTER TABLE product_categories ADD COLUMN slug_en VARCHAR(64) NULL DEFAULT NULL AFTER slug', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND COLUMN_NAME = 'page_title_en');
SET @sql := IF(@c = 0, 'ALTER TABLE product_categories ADD COLUMN page_title_en VARCHAR(255) NULL DEFAULT NULL AFTER page_title', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND COLUMN_NAME = 'meta_keywords_en');
SET @sql := IF(@c = 0, 'ALTER TABLE product_categories ADD COLUMN meta_keywords_en TEXT NULL AFTER meta_keywords', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND COLUMN_NAME = 'meta_description_en');
SET @sql := IF(@c = 0, 'ALTER TABLE product_categories ADD COLUMN meta_description_en TEXT NULL AFTER meta_description', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @uq := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'product_categories' AND INDEX_NAME = 'uq_product_categories_slug_en');
SET @sql := IF(@uq = 0, 'ALTER TABLE product_categories ADD UNIQUE KEY uq_product_categories_slug_en (slug_en)', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

-- facet_definitions / facet_values (tablo varsa)
SET @t := (SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'facet_definitions');
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'facet_definitions' AND COLUMN_NAME = 'label_en');
SET @sql := IF(@t > 0 AND @c = 0, 'ALTER TABLE facet_definitions ADD COLUMN label_en VARCHAR(255) NULL DEFAULT NULL AFTER label', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @t := (SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'facet_values');
SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'facet_values' AND COLUMN_NAME = 'label_en');
SET @sql := IF(@t > 0 AND @c = 0, 'ALTER TABLE facet_values ADD COLUMN label_en VARCHAR(255) NULL DEFAULT NULL AFTER label', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
