diff --git a/make/common/db/registry.sql b/make/common/db/registry.sql index d3412223a..762a20acf 100644 --- a/make/common/db/registry.sql +++ b/make/common/db/registry.sql @@ -43,7 +43,7 @@ create table user ( # The mark of deleted user is "#user_id". # The 11 consist of 10 for the max value of user_id(4294967295) # in MySQL and 1 of '#'. - username varchar(32), + username varchar(255), # 11 bytes is reserved for marking the deleted users. email varchar(255), password varchar(40) NOT NULL, @@ -99,7 +99,7 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim create table access_log ( log_id int NOT NULL AUTO_INCREMENT, - username varchar (32) NOT NULL, + username varchar (255) NOT NULL, project_id int NOT NULL, repo_name varchar (256), repo_tag varchar (128), @@ -142,7 +142,7 @@ create table replication_target ( id int NOT NULL AUTO_INCREMENT, name varchar(64), url varchar(64), - username varchar(40), + username varchar(255), password varchar(128), /* target_type indicates the type of target registry, diff --git a/make/common/db/registry_sqlite.sql b/make/common/db/registry_sqlite.sql index 257176788..21028859c 100644 --- a/make/common/db/registry_sqlite.sql +++ b/make/common/db/registry_sqlite.sql @@ -38,7 +38,7 @@ create table user ( The 11 consist of 10 for the max value of user_id(4294967295) in MySQL and 1 of '#'. */ - username varchar(32), + username varchar(255), /* 11 bytes is reserved for marking the deleted users. */ @@ -96,7 +96,7 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim create table access_log ( log_id INTEGER PRIMARY KEY, - username varchar (32) NOT NULL, + username varchar (255) NOT NULL, project_id int NOT NULL, repo_name varchar (256), repo_tag varchar (128), @@ -137,7 +137,7 @@ create table replication_target ( id INTEGER PRIMARY KEY, name varchar(64), url varchar(64), - username varchar(40), + username varchar(255), password varchar(128), /* target_type indicates the type of target registry, diff --git a/src/common/dao/accesslog.go b/src/common/dao/accesslog.go index b99cd7bbf..c0f716fdc 100644 --- a/src/common/dao/accesslog.go +++ b/src/common/dao/accesslog.go @@ -22,6 +22,12 @@ import ( // AddAccessLog persists the access logs func AddAccessLog(accessLog models.AccessLog) error { + // the max length of username in database is 255, replace the last + // three charaters with "..." if the length is greater than 256 + if len(accessLog.Username) > 255 { + accessLog.Username = accessLog.Username[:252] + "..." + } + o := GetOrmer() _, err := o.Insert(&accessLog) return err