作者 tangxvhui

Merge branch 'test'

正在显示 1 个修改的文件 包含 53 行增加0 行删除
... ... @@ -90,3 +90,56 @@ CREATE TABLE public.task_stage(
CONSTRAINT task_stage_pkey PRIMARY KEY (id)
);
-- 公司添加超级管理员(不存在时插入新数据)
INSERT INTO public."role"("name", "type", description, company_id, created_at, updated_at, deleted_at)
SELECT
'超级管理员',
2,
'隐藏角色,拥有部分权限',
1,
now(),
now(),
NULL
WHERE
NOT EXISTS (
SELECT
1
FROM
public."role"
WHERE
"role".company_id = 1
AND "role"."type" = 2
AND "role".deleted_at ISNULL);
-- -------------------------------------------------------------------------
-- 超级管理员关联用户(不存在时插入新数据)
WITH temp_role AS (
SELECT
id
FROM
public."role"
WHERE
"role".company_id = 1
AND "role"."type" = 2)
INSERT INTO public."role_user"(role_id, user_id, company_id, created_at, updated_at, deleted_at)
SELECT
temp_role."id",
3242583253399296,
1,
now(),
now(),
NULL
FROM
temp_role
WHERE
NOT EXISTS (
SELECT
1
FROM
public."role_user"
WHERE
"role_user".company_id = 1
AND "role_user".user_id = 3242583253399296
AND "role_user".role_id = temp_role."id"
AND "role_user".deleted_at ISNULL);
... ...