mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Merge pull request #45 from reasonerjt/db-role-refactor
update sql script for role refactor in db
This commit is contained in:
commit
5b97623fee
@ -10,27 +10,30 @@ create table access (
|
|||||||
primary key (access_id)
|
primary key (access_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into access values
|
insert into access (access_code, comment) values
|
||||||
( null, 'A', 'All access for the system'),
|
('M', 'Management access for project'),
|
||||||
( null, 'M', 'Management access for project'),
|
('R', 'Read access for project'),
|
||||||
( null, 'R', 'Read access for project'),
|
('W', 'Write access for project'),
|
||||||
( null, 'W', 'Write access for project'),
|
('D', 'Delete access for project'),
|
||||||
( null, 'D', 'Delete access for project'),
|
('S', 'Search access for project');
|
||||||
( null, 'S', 'Search access for project');
|
|
||||||
|
|
||||||
|
|
||||||
create table role (
|
create table role (
|
||||||
role_id int NOT NULL AUTO_INCREMENT,
|
role_id int NOT NULL AUTO_INCREMENT,
|
||||||
|
role_mask int DEFAULT 0 NOT NULL,
|
||||||
role_code varchar(20),
|
role_code varchar(20),
|
||||||
name varchar (20),
|
name varchar (20),
|
||||||
primary key (role_id)
|
primary key (role_id)
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
|
role mask is used for future enhancement when a project member can have multi-roles
|
||||||
|
currently set to 0
|
||||||
|
*/
|
||||||
|
|
||||||
insert into role values
|
insert into role (role_code, name) values
|
||||||
( null, 'AMDRWS', 'sysAdmin'),
|
('MDRWS', 'projectAdmin'),
|
||||||
( null, 'MDRWS', 'projectAdmin'),
|
('RWS', 'developer'),
|
||||||
( null, 'RWS', 'developer'),
|
('RS', 'guest');
|
||||||
( null, 'RS', 'guest');
|
|
||||||
|
|
||||||
|
|
||||||
create table user (
|
create table user (
|
||||||
@ -43,20 +46,24 @@ create table user (
|
|||||||
deleted tinyint (1) DEFAULT 0 NOT NULL,
|
deleted tinyint (1) DEFAULT 0 NOT NULL,
|
||||||
reset_uuid varchar(40) DEFAULT NULL,
|
reset_uuid varchar(40) DEFAULT NULL,
|
||||||
salt varchar(40) DEFAULT NULL,
|
salt varchar(40) DEFAULT NULL,
|
||||||
|
sysadmin_flag tinyint (1),
|
||||||
|
creation_time timestamp,
|
||||||
|
update_time timestamp,
|
||||||
primary key (user_id),
|
primary key (user_id),
|
||||||
UNIQUE (username),
|
UNIQUE (username),
|
||||||
UNIQUE (email)
|
UNIQUE (email)
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into user values
|
insert into user (username, email, password, realname, comment, deleted, sysadmin_flag, creation_time, update_time) values
|
||||||
(1, 'admin', 'admin@example.com', '', 'system admin', 'admin user',0, null, ''),
|
('admin', 'admin@example.com', '', 'system admin', 'admin user',0, 1, NOW(), NOW()),
|
||||||
(2, 'anonymous', 'anonymous@example.com', '', 'anonymous user', 'anonymous user', 1, null, '');
|
('anonymous', 'anonymous@example.com', '', 'anonymous user', 'anonymous user', 1, 0, NOW(), NOW());
|
||||||
|
|
||||||
create table project (
|
create table project (
|
||||||
project_id int NOT NULL AUTO_INCREMENT,
|
project_id int NOT NULL AUTO_INCREMENT,
|
||||||
owner_id int NOT NULL,
|
owner_id int NOT NULL,
|
||||||
name varchar (30) NOT NULL,
|
name varchar (30) NOT NULL,
|
||||||
creation_time timestamp,
|
creation_time timestamp,
|
||||||
|
update_time timestamp,
|
||||||
deleted tinyint (1) DEFAULT 0 NOT NULL,
|
deleted tinyint (1) DEFAULT 0 NOT NULL,
|
||||||
public tinyint (1) DEFAULT 0 NOT NULL,
|
public tinyint (1) DEFAULT 0 NOT NULL,
|
||||||
primary key (project_id),
|
primary key (project_id),
|
||||||
@ -64,32 +71,23 @@ create table project (
|
|||||||
UNIQUE (name)
|
UNIQUE (name)
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into project values
|
insert into project (owner_id, name, creation_time, update_time, public) values
|
||||||
(null, 1, 'library', NOW(), 0, 1);
|
(1, 'library', NOW(), NOW(), 1);
|
||||||
|
|
||||||
create table project_role (
|
create table project_member (
|
||||||
pr_id int NOT NULL AUTO_INCREMENT,
|
|
||||||
project_id int NOT NULL,
|
project_id int NOT NULL,
|
||||||
role_id int NOT NULL,
|
|
||||||
primary key (pr_id),
|
|
||||||
FOREIGN KEY (role_id) REFERENCES role(role_id),
|
|
||||||
FOREIGN KEY (project_id) REFERENCES project (project_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
insert into project_role values
|
|
||||||
( 1,1,1 );
|
|
||||||
|
|
||||||
create table user_project_role (
|
|
||||||
upr_id int NOT NULL AUTO_INCREMENT,
|
|
||||||
user_id int NOT NULL,
|
user_id int NOT NULL,
|
||||||
pr_id int NOT NULL,
|
role int NOT NULL,
|
||||||
primary key (upr_id),
|
creation_time timestamp,
|
||||||
FOREIGN KEY (user_id) REFERENCES user(user_id),
|
update_time timestamp,
|
||||||
FOREIGN KEY (pr_id) REFERENCES project_role (pr_id)
|
PRIMARY KEY (project_id, user_id),
|
||||||
);
|
FOREIGN KEY (role) REFERENCES role(role_id),
|
||||||
|
FOREIGN KEY (project_id) REFERENCES project(project_id),
|
||||||
|
FOREIGN KEY (user_id) REFERENCES user(user_id)
|
||||||
|
);
|
||||||
|
|
||||||
insert into user_project_role values
|
insert into project_member (project_id, user_id, role, creation_time, update_time) values
|
||||||
( 1,1,1 );
|
(1, 1, 1, NOW(), NOW());
|
||||||
|
|
||||||
create table access_log (
|
create table access_log (
|
||||||
log_id int NOT NULL AUTO_INCREMENT,
|
log_id int NOT NULL AUTO_INCREMENT,
|
||||||
|
Loading…
Reference in New Issue
Block a user