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

function migrate_028($pdo) {
    try {
        $sql = "ALTER TABLE process_definitions ADD COLUMN sort_order INT NOT NULL DEFAULT 0 AFTER is_active";
        $pdo->exec($sql);
        echo "Migration successful: sort_order column added to process_definitions table.\n";
    } catch (PDOException $e) {
        // Ignore if column already exists
        if (strpos($e->getMessage(), 'Duplicate column name') === false) {
            die("Migration failed: " . $e->getMessage() . "\n");
        }
    }
}

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

