36274-vm/db/migrate.php
Flatlogic Bot 76b95bec18 v1
2025-11-25 15:04:51 +00:00

35 lines
786 B
PHP

<?php
// Simple migration script
require_once __DIR__ . '/config.php';
function run_migrations() {
try {
$pdo = db();
$migrationsDir = __DIR__ . '/migrations';
if (!is_dir($migrationsDir)) {
echo "Migrations directory not found.\n";
return;
}
$files = glob($migrationsDir . '/*.sql');
sort($files);
foreach ($files as $file) {
echo "Running migration: " . basename($file) . "...\n";
$sql = file_get_contents($file);
$pdo->exec($sql);
echo "Success.\n";
}
echo "\nAll migrations completed.\n";
} catch (PDOException $e) {
die("Database migration failed: " . $e->getMessage() . "\n");
}
}
run_migrations();