PDO::ERRMODE_EXCEPTION, ]); $pdo->exec('CREATE DATABASE IF NOT EXISTS '.DB_NAME); echo "Database created or already exists." . PHP_EOL; // Now connect to the specific database $pdo = db(); $migrations = glob(__DIR__ . '/migrations/*.sql'); sort($migrations); foreach ($migrations as $migration) { $sql = file_get_contents($migration); $pdo->exec($sql); echo "Executed migration: $migration" . PHP_EOL; } } catch (PDOException $e) { die("Database migration failed: " . $e->getMessage()); }