harbor/make/migrations/postgresql/0050_2.2.0_schema.up.sql
Wang Yan ec15e320bf add role permission manager for robot enhancement
1, add two db tables of role permission and rbac policy
2, add manager of these two tables

Signed-off-by: Wang Yan <wangyan@vmware.com>
2020-11-10 16:49:29 +08:00

43 lines
1.2 KiB
SQL

ALTER TABLE schedule ADD COLUMN IF NOT EXISTS cron_type varchar(64);
<<<<<<< HEAD
DO $$
DECLARE
art RECORD;
art_size integer;
BEGIN
FOR art IN SELECT * FROM artifact WHERE size = 0
LOOP
SELECT sum(size) INTO art_size FROM blob WHERE digest IN (SELECT digest_blob FROM artifact_blob WHERE digest_af=art.digest);
UPDATE artifact SET size=art_size WHERE id = art.id;
END LOOP;
END $$;
=======
ALTER TABLE robot ADD COLUMN IF NOT EXISTS secret varchar(2048);
CREATE TABLE IF NOT EXISTS role_permission (
id SERIAL PRIMARY KEY NOT NULL,
role_type varchar(255) NOT NULL,
role_id int NOT NULL,
rbac_policy_id int NOT NULL,
creation_time timestamp default CURRENT_TIMESTAMP,
CONSTRAINT unique_role_permission UNIQUE (role_type, role_id, rbac_policy_id)
);
CREATE TABLE IF NOT EXISTS rbac_policy (
id SERIAL PRIMARY KEY NOT NULL,
/*
scope:
system level: /system
project level: /project/{id}
all project: /project/ *
*/
scope varchar(255) NOT NULL,
resource varchar(255),
action varchar(255),
effect varchar(255),
creation_time timestamp default CURRENT_TIMESTAMP,
CONSTRAINT unique_rbac_policy UNIQUE (scope, resource, action, effect)
);
>>>>>>> ae2bcebdd (add role permission manager for robot enhancement)