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

function migrate_029($pdo) {
    $process_order = [
        'Przygotowanie spotkania grupy' => 10,
        'Follow-up' => 20,
        'Obsługa przyjęcia nowego członka' => 30,
        'Wprowadzenie nowego członka' => 40,
        'Szkolenia dla młodego członka' => 50,
        'Mentoring' => 60,
    ];

    try {
        $stmt = $pdo->prepare("UPDATE process_definitions SET sort_order = :sort_order WHERE name = :name");

        foreach ($process_order as $name => $order) {
            $stmt->execute(['sort_order' => $order, 'name' => $name]);
        }

        echo "Migration successful: Initial process order set.\n";
    } catch (PDOException $e) {
        die("Migration failed: " . $e->getMessage() . "\n");
    }
}

if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
    require_once __DIR__ . '/../../db/config.php';
    $pdo = db();
    migrate_029($pdo);
}

