37032-vm/db/migrate.php
2025-12-18 07:14:58 +00:00

20 lines
454 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$migration_files = glob(__DIR__ . '/migrations/*.sql');
sort($migration_files);
foreach ($migration_files as $file) {
$sql = file_get_contents($file);
$pdo->exec($sql);
echo "Migrated: " . basename($file) . "\n";
}
echo "All migrations successful!\n";
} catch (PDOException $e) {
die("Migration failed: " . $e->getMessage() . "\n");
}