<?php
require_once 'config/db.php';

echo "🔍 Verificando estado del chat en la base de datos...\n\n";

// 1. Verificar Esquema Chats
$schema_chats = $pdo->query("DESCRIBE chats")->fetchAll(PDO::FETCH_ASSOC);
echo "--- Schema Chats ---\n";
print_r($schema_chats);

// 2. Verificar Esquema Messages
$schema_messages = $pdo->query("DESCRIBE messages")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Schema Messages ---\n";
print_r($schema_messages);

// 3. Verificar Esquema Members
$schema_members = $pdo->query("DESCRIBE chat_members")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Schema Chat Members ---\n";
print_r($schema_members);

// 4. Verificar Datos
$chats = $pdo->query("SELECT * FROM chats")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Chats (" . count($chats) . ") ---\n";
print_r($chats);

$members = $pdo->query("SELECT * FROM chat_members")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Chat Members (" . count($members) . ") ---\n";
print_r($members);

$messages = $pdo->query("SELECT * FROM messages")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Messages (" . count($messages) . ") ---\n";
print_r($messages);

// 4. Verificar Usuarios (i_users)
$users = $pdo->query("SELECT iuid, i_username, diamonds FROM i_users LIMIT 5")->fetchAll(PDO::FETCH_ASSOC);
echo "\n--- Usuarios Reales (Resumen) ---\n";
print_r($users);
?>
