22 lines
596 B
PHP
22 lines
596 B
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
function run_migrations() {
|
|
$pdo = db();
|
|
$migrations_dir = __DIR__ . '/migrations';
|
|
$files = glob($migrations_dir . '/*.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";
|
|
// You might want to log this or handle it more gracefully
|
|
}
|
|
}
|
|
}
|
|
|
|
run_migrations(); |