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

function migrate_014_add_role_to_people_table() {
    $pdo = db();

    // Check if the column already exists
    try {
        $result = $pdo->query("SELECT `role` FROM `people` LIMIT 1");
    } catch (PDOException $e) {
        // Column does not exist, so add it
        $pdo->exec("ALTER TABLE `people` ADD COLUMN `role` VARCHAR(50) NOT NULL DEFAULT 'członek' AFTER `email`");
        echo "Migration 014: Added 'role' column to 'people' table.\n";
        return;
    }

    echo "Migration 014: 'role' column already exists in 'people' table. No changes made.\n";
}

migrate_014_add_role_to_people_table();

