-- Helpdesk module: per-tenant BC connection settings override
CREATE TABLE IF NOT EXISTS `helpdesk_tenant_settings` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `tenant_id` INT UNSIGNED NOT NULL,
    `override_enabled` TINYINT(1) NOT NULL DEFAULT 0,
    `auth_mode` VARCHAR(20) DEFAULT NULL,
    `odata_base_url` VARCHAR(500) DEFAULT NULL,
    `company_name` VARCHAR(255) DEFAULT NULL,
    `basic_user` VARCHAR(255) DEFAULT NULL,
    `basic_password_enc` TEXT DEFAULT NULL,
    `oauth_tenant_id` VARCHAR(255) DEFAULT NULL,
    `oauth_client_id` VARCHAR(255) DEFAULT NULL,
    `oauth_client_secret_enc` TEXT DEFAULT NULL,
    `oauth_token_endpoint` VARCHAR(500) DEFAULT NULL,
    `system_recommendations_config` TEXT DEFAULT NULL,
    `controlling_risk_config` TEXT DEFAULT NULL,
    `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE INDEX `idx_helpdesk_tenant_settings_tenant` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
