Files
zt-dsc/sql/dm/新增用户与组织关系表并迁移.sql
Administrator 06b278563e v 1.0
1. 新增用户与部门,一对多的关系;
2. 新增管理多部门用户,如果有为公司的多个部门可以进行选择登录(选择后,直到下次变更访问公司前,只能访问此次选择公的业务数据,使用 company_id 控制,后续补充此数据权限的实现);
3. sql 转化工具修复,现在可以正确的对 mysql 进行不同数据库实例的转化了;
4. 所有表格主键,修改为分布式 Id 实现;
5. 补全在初始版本中没有被纳入的其他预制功能模块
2025-07-01 07:30:25 +00:00

42 lines
2.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
create table "RUOYI-VUE-PRO".SYSTEM_USER_DEPT (
ID BIGINT primary key, -- 自增主键
USER_ID BIGINT not null,
DEPT_ID BIGINT not null,
TENANT_ID BIGINT default 0 not null,
REMARK VARCHAR(2000),
CREATOR VARCHAR(256) default '',
CREATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
UPDATER VARCHAR(256) default '',
DELETED TINYINT default 0 not null,
UPDATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null
);
comment on table "RUOYI-VUE-PRO".SYSTEM_USER_DEPT is '用户与部门关系表';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.ID is '主键ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.USER_ID is '用户ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.DEPT_ID is '部门ID';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.TENANT_ID is '租户编号';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.REMARK is '备注';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.CREATOR is '创建者';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.CREATE_TIME is '创建时间';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.UPDATER is '更新者';
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.UPDATE_TIME is '更新时间';
-- 1. 将原有用户表中的 DEPT_ID 字段数据迁移到关系表ID 自增,无需指定)
insert into "RUOYI-VUE-PRO".SYSTEM_USER_DEPT (
USER_ID, DEPT_ID, TENANT_ID, REMARK, CREATOR, CREATE_TIME, UPDATER, UPDATE_TIME
)
select
ID as USER_ID,
DEPT_ID,
TENANT_ID,
null as REMARK,
CREATOR,
CREATE_TIME,
UPDATER,
UPDATE_TIME
from "RUOYI-VUE-PRO".SYSTEM_USERS
where DEPT_ID is not null;
-- 移除用户表中的 DEPT_ID 字段
alter table "RUOYI-VUE-PRO".SYSTEM_USERS drop column DEPT_ID;