35 lines
786 B
PHP
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();
|
|
|