Merge pull request #3072 from ywk253100/170817_username

[BAT]Increase length of username in database to 255
This commit is contained in:
Wenkai Yin 2017-08-17 17:41:34 +08:00 committed by GitHub
commit 19d3cf3e3a
3 changed files with 12 additions and 6 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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