<?php
require_once 'lomba/db.php';

function columnExists($mysqli, $table, $column) {
    $res = $mysqli->query("SHOW COLUMNS FROM `$table` LIKE '$column'");
    return $res && $res->num_rows > 0;
}

if (!columnExists($mysqli, 'users', 'color_blindness_type')) {
    if ($mysqli->query("ALTER TABLE users ADD COLUMN color_blindness_type VARCHAR(50) DEFAULT 'none'")) {
        echo "Added color_blindness_type\n";
    } else {
        echo "Error adding color_blindness_type: " . $mysqli->error . "\n";
    }
} else {
    echo "color_blindness_type already exists\n";
}

if (!columnExists($mysqli, 'users', 'color_blindness_enabled')) {
    if ($mysqli->query("ALTER TABLE users ADD COLUMN color_blindness_enabled TINYINT(1) DEFAULT 0")) {
        echo "Added color_blindness_enabled\n";
    } else {
        echo "Error adding color_blindness_enabled: " . $mysqli->error . "\n";
    }
} else {
    echo "color_blindness_enabled already exists\n";
}
?>
