PDO::ERRMODE_EXCEPTION, ]); // Create the database if it doesn't exist $pdo->exec('CREATE DATABASE IF NOT EXISTS `'.DB_NAME.'`'); // 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: " . basename($migration) . "\n"; } echo "Migrations completed successfully.\n"; } catch (PDOException $e) { die("Migration failed: " . $e->getMessage()); }