34766-vm/db/migrate.php
2025-10-07 19:47:56 +00:00

19 lines
419 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$migrationsDir = __DIR__ . '/migrations';
$files = glob($migrationsDir . '/*.sql');
foreach ($files as $file) {
$sql = file_get_contents($file);
$pdo->exec($sql);
echo "Migration from $file executed successfully.\n";
}
} catch (PDOException $e) {
die("Database migration failed: " . $e->getMessage());
}