63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
require_once 'config/config.php';
|
|
require_once 'classes/Database.php';
|
|
|
|
try {
|
|
$db = Database::getInstance();
|
|
$conn = $db->getConnection();
|
|
|
|
// Leer el archivo SQL
|
|
$sqlFile = __DIR__ . '/create_media_table.sql';
|
|
|
|
if (!file_exists($sqlFile)) {
|
|
throw new Exception("Archivo SQL no encontrado: $sqlFile");
|
|
}
|
|
|
|
$sql = file_get_contents($sqlFile);
|
|
|
|
if (empty($sql)) {
|
|
throw new Exception("El archivo SQL está vacío");
|
|
}
|
|
|
|
// Ejecutar el SQL
|
|
$result = $conn->query($sql);
|
|
|
|
if ($result === false) {
|
|
throw new Exception("Error al ejecutar SQL: " . $conn->error);
|
|
}
|
|
|
|
echo "✅ Tabla 'media_files' creada exitosamente\n\n";
|
|
|
|
// Verificar que la tabla existe
|
|
$check = $conn->query("SHOW TABLES LIKE 'media_files'");
|
|
if ($check && $check->num_rows > 0) {
|
|
echo "✅ Tabla verificada en la base de datos\n\n";
|
|
|
|
// Mostrar estructura de la tabla
|
|
$structure = $conn->query("DESCRIBE media_files");
|
|
if ($structure) {
|
|
echo "📋 Estructura de la tabla:\n";
|
|
echo str_repeat("-", 80) . "\n";
|
|
printf("%-20s %-20s %-10s %-10s %-20s\n", "Campo", "Tipo", "Null", "Key", "Extra");
|
|
echo str_repeat("-", 80) . "\n";
|
|
|
|
while ($row = $structure->fetch_assoc()) {
|
|
printf("%-20s %-20s %-10s %-10s %-20s\n",
|
|
$row['Field'],
|
|
$row['Type'],
|
|
$row['Null'],
|
|
$row['Key'],
|
|
$row['Extra']
|
|
);
|
|
}
|
|
echo str_repeat("-", 80) . "\n";
|
|
}
|
|
} else {
|
|
echo "⚠️ La tabla no se pudo verificar\n";
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo "❌ Error: " . $e->getMessage() . "\n";
|
|
exit(1);
|
|
}
|