22 lines
557 B
PHP
22 lines
557 B
PHP
<?php
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
function runMigrations() {
|
|
$pdo = db();
|
|
$migrationsDir = __DIR__;
|
|
$files = glob($migrationsDir . '/*.sql');
|
|
sort($files);
|
|
|
|
foreach ($files as $file) {
|
|
$sql = file_get_contents($file);
|
|
try {
|
|
$pdo->exec($sql);
|
|
echo "Successfully applied migration: " . basename($file) . PHP_EOL;
|
|
} catch (PDOException $e) {
|
|
echo "Error applying migration " . basename($file) . ": " . $e->getMessage() . PHP_EOL;
|
|
}
|
|
}
|
|
}
|
|
|
|
runMigrations();
|