PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); } catch (PDOException $e) { // If the database doesn't exist, you might want to handle that here // For now, we'll just re-throw the exception. throw $e; } } return $pdo; } function run_migrations() { $pdo = db(); $migrations_dir = __DIR__ . '/migrations'; if (!is_dir($migrations_dir)) { return; } $files = glob($migrations_dir . '/*.sql'); foreach ($files as $file) { $sql = file_get_contents($file); if ($sql) { $pdo->exec($sql); } } }