CREATE TABLE IF NOT EXISTS chirpstack_servers (
    id INT AUTO_INCREMENT PRIMARY KEY,
    server_name VARCHAR(100) UNIQUE NOT NULL,
    server_url VARCHAR(255) NOT NULL,
    api_key VARCHAR(255) NOT NULL,
    organization_id VARCHAR(100) NOT NULL,
    is_primary BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Create an index for faster lookups
CREATE INDEX idx_chirpstack_server_name ON chirpstack_servers(server_name);
CREATE INDEX idx_chirpstack_primary ON chirpstack_servers(is_primary);
