-- Committee members table structure for member-to-committee assignments.

CREATE TABLE IF NOT EXISTS committee_members (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    committee_name VARCHAR(100) NOT NULL,
    first_name VARCHAR(80) NOT NULL,
    last_name VARCHAR(80) NOT NULL,
    phone VARCHAR(30) NOT NULL,
    email VARCHAR(190) NOT NULL,
    assignment_options JSON NOT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    INDEX idx_committee_name (committee_name),
    INDEX idx_last_name (last_name),
    INDEX idx_email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- For existing tables:
-- ALTER TABLE committee_members ADD COLUMN assignment_options JSON NOT NULL AFTER email;

-- Example insert:
-- INSERT INTO committee_members (committee_name, first_name, last_name, phone, email, assignment_options)
-- VALUES ('Technology', 'Jane', 'Doe', '207-555-0100', 'jane@example.org', JSON_ARRAY('webmaster', 'member'));
