v1_migrate_department_update.sql 1.3 KB
-- 更设置父级部门到公司
update sys.department set parent_id =501 where parent_id = 0
-- 设置部门的id序号
SELECT setval('sys.department_id_seq', 1000);
-- 关联职员表更新职员id
update user_department
set employee_id = employee.id
    from employee
where employee.user_id = user_department.user_id;


/*
-- suplus_enterprise
-- 用户表
select user_id id,name,phone,avatar,UNIX_TIMESTAMP() created_at,UNIX_TIMESTAMP() updated_at,0 deleted_at,0 version,0 is_del from user_info
where  company_id = 1 and user_id <>0 and name ='林忠'

-- 职员表
select uid id,user_id,company_id,'' code,(case when status=1 then 1 else 2 end) account_status,'正式' employee_type,'{}' base_info,'{}' work_info,UNIX_TIMESTAMP() created_at,UNIX_TIMESTAMP() updated_at,0 deleted_at,0 version,0 is_del from user_info
where  company_id = 1 and user_id <>0


-- suplus_business_admin
-- 部门表
select id,company_id,name,'' code,parent_id,'[]' department_heads,false is_root,1 sort,UNIX_TIMESTAMP() created_at,UNIX_TIMESTAMP() updated_at,0 deleted_at,0 version,0 is_del from departments where company_id = 1

-- 用户部门表
select company_id,department_id,user_id,0 employee_id,UNIX_TIMESTAMP() created_at from user_departments where company_id = 1 and deleted_at is null
-- 关联职员表更新职员id
*/