getConnection(); $sql = file_get_contents($sqlFile); $statements = array_filter(array_map('trim', explode(';', $sql))); echo "
🚀 Ejecutando migración: 20260616_turnero_consentimientos_datos\n\n";
foreach ($statements as $stmt) {
$clean = preg_replace('/--[^\n]*/', '', $stmt);
$clean = trim($clean);
if (empty($clean)) continue;
try {
$pdo->exec($clean);
$preview = substr(preg_replace('/\s+/', ' ', $clean), 0, 120);
echo "✓ {$preview}\n";
} catch (PDOException $e) {
$msg = $e->getMessage();
if (str_contains($msg, 'Duplicate column') || str_contains($msg, 'errno: 1060')) {
echo "ℹ️ (columna ya existe, omitida)\n";
} else {
throw $e;
}
}
}
echo "\n✅ Migración completada.\n";
echo " Columna agregada a turnero_consentimientos:\n";
echo " • datos_respuestas (MEDIUMTEXT, JSON con campos llenados al firmar presencialmente)\n";
$cols = $pdo->query("SHOW COLUMNS FROM turnero_consentimientos")->fetchAll(PDO::FETCH_COLUMN);
echo "📋 Columnas actuales: " . implode(', ', $cols) . "";
} catch (Throwable $e) {
echo "❌ Error: " . htmlspecialchars($e->getMessage()) . "\n"; }