-- =========================================================
-- Arkendia • Fix UTF8MB4 Encoding for Ark AI Tables
-- =========================================================
-- Ce script convertit les tables Ark AI en utf8mb4 pour
-- supporter les emojis et caractères spéciaux.
-- =========================================================

USE auth_db;

-- Convertir la table ark_conversations
ALTER TABLE ark_conversations 
  CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Convertir la table ark_messages  
ALTER TABLE ark_messages 
  CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Convertir la table ark_user_preferences
ALTER TABLE ark_user_preferences 
  CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Vérifier les tables converties
SELECT 
    TABLE_NAME,
    TABLE_COLLATION,
    CHARACTER_SET_NAME
FROM 
    information_schema.TABLES t
    JOIN information_schema.COLLATION_CHARACTER_SET_APPLICABILITY c
        ON t.TABLE_COLLATION = c.COLLATION_NAME
WHERE 
    TABLE_SCHEMA = 'auth_db'
    AND TABLE_NAME LIKE 'ark_%';
