36525-vm/db/migrate.php
Flatlogic Bot 232ed5c114 V3
2025-12-01 09:10:54 +00:00

22 lines
596 B
PHP

<?php
require_once __DIR__ . '/config.php';
function run_migrations() {
$pdo = db();
$migrations_dir = __DIR__ . '/migrations';
$files = glob($migrations_dir . '/*.sql');
sort($files);
foreach ($files as $file) {
echo "Running migration: " . basename($file) . "\n";
$sql = file_get_contents($file);
try {
$pdo->exec($sql);
} catch (PDOException $e) {
echo "Error running migration: " . $e->getMessage() . "\n";
// You might want to log this or handle it more gracefully
}
}
}
run_migrations();