CREATE TABLE IF NOT EXISTS UM_UUID_DOMAIN_MAPPER
(
    UM_ID        INTEGER      NOT NULL AUTO_INCREMENT,
    UM_USER_ID   VARCHAR(255) NOT NULL,
    UM_DOMAIN_ID INTEGER      NOT NULL,
    UM_TENANT_ID INTEGER DEFAULT 0,
    PRIMARY KEY (UM_ID),
    UNIQUE (UM_USER_ID),
    FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN (UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE
) ENGINE INNODB;

-- Indexes
CREATE INDEX UUID_DM_UID_TID ON UM_UUID_DOMAIN_MAPPER (UM_USER_ID, UM_TENANT_ID);
