<?php

return <<<'SQL'
CREATE TABLE tenant_identity_providers (
    id CHAR(36) NOT NULL PRIMARY KEY,
    tenant_id CHAR(36) NOT NULL,
    provider_key VARCHAR(120) NOT NULL,
    driver VARCHAR(50) NOT NULL DEFAULT 'oidc',
    display_name VARCHAR(255) NOT NULL,
    client_id VARCHAR(255) NOT NULL,
    client_secret_encrypted VARCHAR(1024) NULL,
    discovery_url VARCHAR(1024) NULL,
    authorization_url VARCHAR(1024) NULL,
    token_url VARCHAR(1024) NULL,
    userinfo_url VARCHAR(1024) NULL,
    redirect_uri VARCHAR(1024) NOT NULL,
    scopes TEXT NULL,
    is_enabled BIT NOT NULL DEFAULT 1,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    UNIQUE (tenant_id, provider_key),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
SQL;
