up
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Ejecuta la migración 005_registro_exams.sql
|
||||
* Acceder UNA VEZ desde el navegador como administrador, luego borrar.
|
||||
*/
|
||||
require_once __DIR__ . '/config/config.php';
|
||||
if (!isUserLoggedIn()) { header('Location: ' . BASE_URL . 'login.php'); exit; }
|
||||
|
||||
$pdo = Database::getInstance()->getConnection();
|
||||
$sqlFile = __DIR__ . '/migrations/005_registro_exams.sql';
|
||||
$sql = file_get_contents($sqlFile);
|
||||
|
||||
// Separar sentencias (ignorar comentarios)
|
||||
$statements = array_filter(array_map('trim', explode(';', $sql)));
|
||||
|
||||
$results = [];
|
||||
foreach ($statements as $stmt) {
|
||||
if (empty($stmt) || preg_match('/^\s*--/', $stmt)) continue;
|
||||
try {
|
||||
$pdo->exec($stmt);
|
||||
$results[] = ['ok' => true, 'sql' => substr(preg_replace('/\s+/', ' ', $stmt), 0, 120)];
|
||||
} catch (\PDOException $e) {
|
||||
$results[] = ['ok' => false, 'sql' => substr(preg_replace('/\s+/', ' ', $stmt), 0, 120), 'error' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
?><!DOCTYPE html>
|
||||
<html lang="es"><head><meta charset="UTF-8"><title>Migración 005</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head><body class="p-4">
|
||||
<h4>Migración 005 — Registro de Exámenes</h4>
|
||||
<table class="table table-sm table-bordered small">
|
||||
<thead><tr><th>#</th><th>Estado</th><th>SQL</th><th>Error</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($results as $i => $r): ?>
|
||||
<tr class="<?= $r['ok'] ? 'table-success' : 'table-danger' ?>">
|
||||
<td><?= $i+1 ?></td>
|
||||
<td><?= $r['ok'] ? '✓ OK' : '✗ Error' ?></td>
|
||||
<td><code><?= htmlspecialchars($r['sql']) ?>…</code></td>
|
||||
<td><?= htmlspecialchars($r['error'] ?? '') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="alert alert-warning mt-3">⚠️ Elimina este archivo del servidor después de ejecutarlo.</div>
|
||||
<a href="<?= BASE_URL ?>erp.php?m=registro_exams&v=lista" class="btn btn-primary">Ir a Registro Exámenes</a>
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user