审查视图

sql/1.2.4.sql 1.5 KB
郑周 authored
1
-- 权限表建新列
郑周 authored
2 3 4 5
ALTER TABLE public."permission"
    ADD opt_confirm_perf int8 NULL DEFAULT 1;
COMMENT
ON COLUMN public."permission".opt_confirm_perf IS '是否需要员工确认绩效';
郑周 authored
6
郑周 authored
7 8 9 10
ALTER TABLE public."permission"
    ADD cycle_deadline jsonb NULL;
COMMENT
ON COLUMN public."permission".cycle_deadline IS '周期评估各业务截止时间';
郑周 authored
11
郑周 authored
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

-- 公司添加超级管理员(不存在时插入新数据)(注.公司ID->416)
insert
into
    public."role"
( "name",
  "type",
  description,
  company_id,
  created_at,
  updated_at,
  deleted_at)
select
    '超级管理员',
    2,
    '隐藏角色,拥有部分权限',
    416,
    now(),
    now(),
    null
    where
	not exists (
	select
		1
	from
		public."role"
	where
		"role".company_id = 416
		and "role"."type" = 2);

--	超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416  用户ID->3337322891762688)
with temp_role as (
    select
        id
    from
        public."role"
    where
郑周 authored
49 50
      "role".company_id = 416
      and "role"."type" = 2)
郑周 authored
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
insert
into
	public."role_user"
( role_id,
	user_id,
	company_id,
	created_at,
	updated_at,
	deleted_at)
select
    temp_role."id",
    3337322891762688,
    416,
    now(),
    now(),
    null
from
    temp_role
where
郑周 authored
70
    not exists(
郑周 authored
71 72 73 74 75
            select
                1
            from
                public."role_user"
            where
郑周 authored
76
              "role_user".company_id = 416
郑周 authored
77 78
              and "role_user".user_id = 3337322891762688
              and "role_user".role_id = temp_role."id");
郑周 authored
79
--