Create run_migration_lugar_consentimientos.php
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Runner — Migración 20260422: turnero_lugar_consentimientos
|
||||
* Ejecutar una sola vez desde el navegador o CLI.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/config/config.php';
|
||||
|
||||
$sqlFile = __DIR__ . '/migrations/20260422_turnero_lugar_consentimientos.sql';
|
||||
|
||||
if (!file_exists($sqlFile)) {
|
||||
die("❌ Archivo no encontrado: $sqlFile\n");
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = Database::getInstance()->getConnection();
|
||||
$sql = file_get_contents($sqlFile);
|
||||
|
||||
// Separar sentencias
|
||||
$statements = array_filter(array_map('trim', explode(';', $sql)));
|
||||
|
||||
echo "<pre>🚀 Ejecutando migración: 20260422_turnero_lugar_consentimientos\n\n";
|
||||
|
||||
foreach ($statements as $stmt) {
|
||||
// Saltar líneas vacías y comentarios puros
|
||||
$clean = preg_replace('/--[^\n]*/', '', $stmt);
|
||||
$clean = trim($clean);
|
||||
if (empty($clean)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdo->exec($clean);
|
||||
$preview = substr(preg_replace('/\s+/', ' ', $clean), 0, 100);
|
||||
echo "✓ Ejecutado: {$preview}\n";
|
||||
}
|
||||
|
||||
echo "\n✅ Migración completada. Tabla <strong>turnero_lugar_consentimientos</strong> creada.\n</pre>";
|
||||
|
||||
} catch (Throwable $e) {
|
||||
echo "<pre>❌ Error: " . htmlspecialchars($e->getMessage()) . "\n</pre>";
|
||||
}
|
||||
Reference in New Issue
Block a user