<?php
require_once __DIR__ . '/../config/config.php';
$db = Database::getInstance();

// Verificar columna message_type
$col = $db->fetch("SHOW COLUMNS FROM conversations LIKE 'message_type'");
if (!$col) {
    echo "Column message_type not found\n";
    exit(1);
}

$type = $col['Type'];
if (strpos($type, "'reaction'") !== false) {
    echo "reaction already present in message_type enum\n";
    exit(0);
}

// Construir nuevo enum
$newEnum = "ENUM('text','image','audio','video','document','template','reaction') NOT NULL DEFAULT 'text'";
try {
    $db->query("ALTER TABLE conversations MODIFY COLUMN message_type $newEnum");
    echo "Added reaction to message_type enum\n";
} catch (Exception $e) {
    echo "Failed to alter table: " . $e->getMessage() . "\n";
    exit(1);
}
