PDO::ERRMODE_EXCEPTION, ]); // Create the database $pdo->exec('CREATE DATABASE IF NOT EXISTS '.DB_NAME); // Now connect to the newly created database $pdo = db(); // Get all migration files and sort them $migration_files = glob('db/migrations/*.sql'); sort($migration_files); // Execute each migration foreach ($migration_files as $file) { $sql = file_get_contents($file); $pdo->exec($sql); } echo "Database setup and all migrations completed successfully."; } catch (PDOException $e) { die("Database setup failed: " . $e->getMessage()); }