30 lines
659 B
PHP
30 lines
659 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Database\ConnectionFactory;
|
|
use Dotenv\Dotenv;
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
$repoRoot = dirname(__DIR__, 2);
|
|
if (file_exists($repoRoot . '/.env')) {
|
|
$dotenv = Dotenv::createImmutable($repoRoot);
|
|
$dotenv->safeLoad();
|
|
}
|
|
|
|
$pdo = ConnectionFactory::create();
|
|
|
|
$migrationsDir = __DIR__ . '/migrations';
|
|
$files = glob($migrationsDir . '/*.sql');
|
|
sort($files);
|
|
|
|
foreach ($files as $file) {
|
|
$sql = file_get_contents($file);
|
|
if ($sql === false) {
|
|
throw new RuntimeException("Migration nicht lesbar: {$file}");
|
|
}
|
|
$pdo->exec($sql);
|
|
echo "OK: " . basename($file) . PHP_EOL;
|
|
}
|