mejoras
This commit is contained in:
+15
-15
@@ -115,10 +115,10 @@ echo "</div>";
|
||||
echo "<div class='section'>";
|
||||
echo "<h2>🔧 CREANDO TABLAS FALTANTES...</h2>";
|
||||
|
||||
// Crear tabla 'messages' como alias de conversations
|
||||
// Crear tabla 'conversations' como alias de conversations
|
||||
try {
|
||||
$pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
CREATE TABLE IF NOT EXISTS conversations (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id INT NOT NULL,
|
||||
phone_number VARCHAR(20) NOT NULL,
|
||||
@@ -132,19 +132,19 @@ try {
|
||||
INDEX idx_created (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
");
|
||||
echo "<div class='ok'>✅ Tabla 'messages' creada</div>";
|
||||
echo "<div class='ok'>✅ Tabla 'conversations' creada</div>";
|
||||
} catch (PDOException $e) {
|
||||
if (strpos($e->getMessage(), 'already exists') === false) {
|
||||
echo "<div class='error'>❌ Error creando tabla messages: " . htmlspecialchars($e->getMessage()) . "</div>";
|
||||
echo "<div class='error'>❌ Error creando tabla conversations: " . htmlspecialchars($e->getMessage()) . "</div>";
|
||||
} else {
|
||||
echo "<div class='warning'>⚠️ Tabla 'messages' ya existe</div>";
|
||||
echo "<div class='warning'>⚠️ Tabla 'conversations' ya existe</div>";
|
||||
}
|
||||
}
|
||||
|
||||
// Crear tabla 'settings' como alias de system_config
|
||||
// Crear tabla 'system_config' como alias de system_config
|
||||
try {
|
||||
$pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS settings (
|
||||
CREATE TABLE IF NOT EXISTS system_config (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
setting_key VARCHAR(100) UNIQUE NOT NULL,
|
||||
setting_value TEXT,
|
||||
@@ -153,25 +153,25 @@ try {
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
");
|
||||
echo "<div class='ok'>✅ Tabla 'settings' creada</div>";
|
||||
echo "<div class='ok'>✅ Tabla 'system_config' creada</div>";
|
||||
} catch (PDOException $e) {
|
||||
if (strpos($e->getMessage(), 'already exists') === false) {
|
||||
echo "<div class='error'>❌ Error creando tabla settings: " . htmlspecialchars($e->getMessage()) . "</div>";
|
||||
echo "<div class='error'>❌ Error creando tabla system_config: " . htmlspecialchars($e->getMessage()) . "</div>";
|
||||
} else {
|
||||
echo "<div class='warning'>⚠️ Tabla 'settings' ya existe</div>";
|
||||
echo "<div class='warning'>⚠️ Tabla 'system_config' ya existe</div>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
// Copiar datos de system_config a settings si no existen
|
||||
// Copiar datos de system_config a system_config si no existen
|
||||
echo "<div class='section'>";
|
||||
echo "<h2>📊 SINCRONIZANDO CONFIGURACIÓN...</h2>";
|
||||
|
||||
try {
|
||||
// Copiar datos de system_config a settings
|
||||
// Copiar datos de system_config a system_config
|
||||
$pdo->exec("
|
||||
INSERT IGNORE INTO settings (setting_key, setting_value, description, created_at)
|
||||
INSERT IGNORE INTO system_config (setting_key, setting_value, description, created_at)
|
||||
SELECT config_key, config_value, description, created_at
|
||||
FROM system_config
|
||||
WHERE config_key IS NOT NULL
|
||||
@@ -188,7 +188,7 @@ try {
|
||||
try {
|
||||
if (!defined('SECRET_KEY') || empty(SECRET_KEY)) {
|
||||
$secret_key = bin2hex(random_bytes(32));
|
||||
$pdo->prepare("INSERT INTO settings (setting_key, setting_value, description) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)")
|
||||
$pdo->prepare("INSERT INTO system_config (setting_key, setting_value, description) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)")
|
||||
->execute(['SECRET_KEY', $secret_key, 'Clave secreta para encriptación']);
|
||||
echo "<div class='ok'>✅ SECRET_KEY generada y guardada</div>";
|
||||
echo "<div class='warning'>🔑 IMPORTANTE: Agrega esta línea a config/config.php:</div>";
|
||||
@@ -204,7 +204,7 @@ echo "</div>";
|
||||
echo "<div class='section'>";
|
||||
echo "<h2>✅ VERIFICACIÓN FINAL</h2>";
|
||||
|
||||
$required_tables = ['conversations', 'messages', 'settings', 'message_templates', 'users', 'menus'];
|
||||
$required_tables = ['conversations', 'conversations', 'system_config', 'message_templates', 'users', 'menus'];
|
||||
$missing_tables = [];
|
||||
|
||||
foreach ($required_tables as $table) {
|
||||
|
||||
Reference in New Issue
Block a user