<?php
require_once __DIR__ . '/config.php';

function run_migrations() {
    $pdo = db();
    $migrationsDir = __DIR__ . '/migrations';
    $migrationFiles = glob($migrationsDir . '/*.sql');

    foreach ($migrationFiles as $file) {
        try {
            $sql = file_get_contents($file);
            $pdo->exec($sql);
            echo "Migration successful: " . basename($file) . "\n";
        } catch (PDOException $e) {
            echo "Migration failed for " . basename($file) . ": " . $e->getMessage() . "\n";
        }
    }
}

run_migrations();

