35239-vm/db/migrate.php
Flatlogic Bot ccc924ba43 ver1
2025-10-26 14:24:09 +00:00

26 lines
617 B
PHP

<?php
require_once __DIR__ . '/config.php';
function run_migrations() {
$pdo = db();
$migrationsDir = __DIR__ . '/migrations';
$files = glob($migrationsDir . '/*.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";
return false;
}
}
echo "Migrations completed successfully.\n";
return true;
}
run_migrations();