-- Video-conferencing link generation: Zoom (Server-to-Server OAuth, tenant supplies its own
-- Account ID/Client ID/Secret) or Google Meet (via Calendar API, reusing the tenant's already-
-- connected Gmail account once it has calendar scope — see AbosGoogleOAuthProperties). One
-- settings row per tenant, same "encrypted secret blob" pattern as tenant_meeting_bot_settings.
-- Idempotent (information_schema-guarded), additive only.
-- Deploy: mysql -u root -p db_abos_v0.1 < db/video_provider_settings.sql

USE db_abos_v0.1;

CREATE TABLE IF NOT EXISTS dim_tenant_video_settings (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    tenant_id INT NOT NULL,
    default_provider VARCHAR(20) NULL COMMENT 'ZOOM, GOOGLE_MEET, or NULL = manual link entry',
    zoom_credentials_encrypted LONGTEXT NULL COMMENT 'v1:<base64> — encrypted JSON {accountId,clientId,clientSecret}, same cipher as SecretDecryptionService',
    created_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6),
    created_by INT NULL,
    updated_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    updated_by INT NULL,
    UNIQUE KEY uq_tenant_video_settings_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
