-- Webroam License Cloud v4.1 schema patch
-- For MySQL versions that do not support IF NOT EXISTS on ALTER TABLE,
-- use tools/migrate.php instead.
ALTER TABLE webroam_licenses ADD COLUMN allowed_remote_sessions_per_day INT NOT NULL DEFAULT 0 AFTER allowed_users;
ALTER TABLE webroam_licenses ADD COLUMN used_endpoints INT NOT NULL DEFAULT 0 AFTER allowed_remote_sessions_per_day;
ALTER TABLE webroam_licenses ADD COLUMN used_users INT NOT NULL DEFAULT 0 AFTER used_endpoints;
ALTER TABLE webroam_licenses ADD COLUMN activation_locked TINYINT(1) NOT NULL DEFAULT 0 AFTER blocked;
ALTER TABLE webroam_licenses ADD COLUMN machine_id VARCHAR(128) DEFAULT NULL AFTER activation_locked;
ALTER TABLE webroam_licenses ADD COLUMN installation_id VARCHAR(128) DEFAULT NULL AFTER machine_id;
ALTER TABLE webroam_licenses ADD COLUMN hostname VARCHAR(255) DEFAULT NULL AFTER installation_id;
ALTER TABLE webroam_licenses ADD COLUMN first_activated_at DATETIME DEFAULT NULL AFTER hostname;
ALTER TABLE webroam_licenses ADD COLUMN last_seen_at DATETIME DEFAULT NULL AFTER first_activated_at;
ALTER TABLE webroam_licenses ADD COLUMN last_check_at DATETIME DEFAULT NULL AFTER last_seen_at;
ALTER TABLE webroam_licenses ADD COLUMN last_action VARCHAR(64) DEFAULT NULL AFTER last_check_at;
ALTER TABLE webroam_licenses ADD COLUMN features TEXT DEFAULT NULL;
CREATE INDEX idx_webroam_licenses_product_key ON webroam_licenses(product_key);
CREATE INDEX idx_webroam_licenses_machine_id ON webroam_licenses(machine_id);
CREATE INDEX idx_webroam_licenses_installation_id ON webroam_licenses(installation_id);
