<?php

return <<<'SQL'
CREATE TABLE user_identities (
    id CHAR(36) NOT NULL PRIMARY KEY,
    user_id CHAR(36) NOT NULL,
    tenant_id CHAR(36) NULL,
    provider_key VARCHAR(120) NOT NULL,
    external_subject VARCHAR(255) NOT NULL,
    email VARCHAR(255) NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    UNIQUE (provider_key, external_subject),
    FOREIGN KEY (user_id) REFERENCES users(id),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
SQL;
