-- 用户-租户关系表
create table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT
(
    ID          BIGINT not null,
    USER_ID     BIGINT not null,
    TENANT_ID   BIGINT not null,
    CREATOR     VARCHAR(256) default '',
    CREATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
    UPDATER     VARCHAR(256) default '',
    UPDATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
    DELETED     TINYINT default 0 not null
);

comment on table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT is '用户-租户关系表';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.ID is '主键ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.USER_ID is '用户ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.TENANT_ID is '租户ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.CREATOR is '创建者';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.CREATE_TIME is '创建时间';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.UPDATER is '更新者';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.UPDATE_TIME is '更新时间';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.DELETED is '是否删除';

create unique index "RUOYI-VUE-PRO".IDX_SYSTEM_USER_TENANT_ID
    on "RUOYI-VUE-PRO".SYSTEM_USER_TENANT (ID);

create unique index "RUOYI-VUE-PRO".IDX_SYSTEM_USER_TENANT_UNIQUE
    on "RUOYI-VUE-PRO".SYSTEM_USER_TENANT (USER_ID, TENANT_ID);

alter table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT
    add constraint PK_SYSTEM_USER_TENANT_ID
        primary key (ID);