38808-vm/db/migrations/migrate.php
2026-02-27 15:17:13 +00:00

22 lines
557 B
PHP

<?php
require_once __DIR__ . '/../config.php';
function runMigrations() {
$pdo = db();
$migrationsDir = __DIR__;
$files = glob($migrationsDir . '/*.sql');
sort($files);
foreach ($files as $file) {
$sql = file_get_contents($file);
try {
$pdo->exec($sql);
echo "Successfully applied migration: " . basename($file) . PHP_EOL;
} catch (PDOException $e) {
echo "Error applying migration " . basename($file) . ": " . $e->getMessage() . PHP_EOL;
}
}
}
runMigrations();