| 123456789101112131415161718192021 |
- -- ----------------------------
- -- 用户与部门关联表 用户1-N部门
- -- ----------------------------
- drop table if exists sys_user_dept;
- create table sys_user_dept
- (
- user_id bigint(20) not null comment '用户ID',
- dept_id bigint(20) not null comment '部门ID',
- post_id bigint(20) not null comment '岗位ID',
- is_main char(1) not null default '0' comment '是否主岗(0否 1是)',
- primary key (user_id, dept_id, post_id)
- ) engine=innodb comment = '用户与部门关联表';
- -- ----------------------------
- -- 初始化-用户与部门关联表数据
- -- 将现有用户数据从sys_user.dept_id迁移过来
- -- ----------------------------
- insert into sys_user_dept (user_id, dept_id)
- select user_id, dept_id
- from sys_user
- where dept_id is not null and del_flag = '0';
|