作者 tangxvhui

更新脚本

正在显示 1 个修改的文件 包含 53 行增加0 行删除
@@ -90,3 +90,56 @@ CREATE TABLE public.task_stage( @@ -90,3 +90,56 @@ CREATE TABLE public.task_stage(
90 CONSTRAINT task_stage_pkey PRIMARY KEY (id) 90 CONSTRAINT task_stage_pkey PRIMARY KEY (id)
91 ); 91 );
92 92
  93 +-- 公司添加超级管理员(不存在时插入新数据)
  94 +INSERT INTO public."role"("name", "type", description, company_id, created_at, updated_at, deleted_at)
  95 +SELECT
  96 + '超级管理员',
  97 + 2,
  98 + '隐藏角色,拥有部分权限',
  99 + 1,
  100 + now(),
  101 + now(),
  102 + NULL
  103 +WHERE
  104 + NOT EXISTS (
  105 + SELECT
  106 + 1
  107 + FROM
  108 + public."role"
  109 + WHERE
  110 + "role".company_id = 1
  111 + AND "role"."type" = 2
  112 + AND "role".deleted_at ISNULL);
  113 +
  114 +-- -------------------------------------------------------------------------
  115 +-- 超级管理员关联用户(不存在时插入新数据)
  116 +WITH temp_role AS (
  117 + SELECT
  118 + id
  119 + FROM
  120 + public."role"
  121 + WHERE
  122 + "role".company_id = 1
  123 + AND "role"."type" = 2)
  124 +INSERT INTO public."role_user"(role_id, user_id, company_id, created_at, updated_at, deleted_at)
  125 +SELECT
  126 + temp_role."id",
  127 + 3242583253399296,
  128 + 1,
  129 + now(),
  130 + now(),
  131 + NULL
  132 +FROM
  133 + temp_role
  134 +WHERE
  135 + NOT EXISTS (
  136 + SELECT
  137 + 1
  138 + FROM
  139 + public."role_user"
  140 + WHERE
  141 + "role_user".company_id = 1
  142 + AND "role_user".user_id = 3242583253399296
  143 + AND "role_user".role_id = temp_role."id"
  144 + AND "role_user".deleted_at ISNULL);
  145 +