27 lines
651 B
PHP
27 lines
651 B
PHP
<?php
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
require_once 'config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$migrations = glob(__DIR__ . '/migrations/*.sql');
|
|
sort($migrations);
|
|
|
|
foreach ($migrations as $migration) {
|
|
$sql = file_get_contents($migration);
|
|
if ($sql) {
|
|
$pdo->exec($sql);
|
|
echo "Executed migration: " . basename($migration) . "<br>";
|
|
}
|
|
}
|
|
|
|
echo "All migrations executed successfully.<br>";
|
|
|
|
} catch (PDOException $e) {
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
die("Database migration failed: " . $e->getMessage());
|
|
}
|