PDO::ERRMODE_EXCEPTION, ]); // Create the database if it doesn't exist $pdo_server->exec('CREATE DATABASE IF NOT EXISTS `'.DB_NAME.'`'); echo "Database `".DB_NAME."` created or already exists.\n"; // Now, connect to the specific database $pdo_db = db(); // Run all migrations $migration_files = glob(__DIR__ . '/migrations/*.sql'); sort($migration_files); foreach ($migration_files as $file) { $sql = file_get_contents($file); $pdo_db->exec($sql); echo "Executed migration: " . basename($file) . "\n"; } echo "All migrations successful!\n"; } catch (PDOException $e) { die("Migration failed: " . $e->getMessage() . "\n"); }