diff options
author | Andrew Bezold <andrew.bezold@gmail.com> | 2021-01-24 10:23:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-24 16:23:05 +0100 |
commit | bc05ddc0ebd6fdc826ef2beec99304bac60ddd8a (patch) | |
tree | 03d52e07feedd37e169a04980f9efbb8bd1aca65 /models/migrations | |
parent | 4f608ad31f538cb45411ff9a2238db812b5ca414 (diff) | |
download | gitea-bc05ddc0ebd6fdc826ef2beec99304bac60ddd8a.tar.gz gitea-bc05ddc0ebd6fdc826ef2beec99304bac60ddd8a.zip |
Redirect on changed user and org name (#11649)
* Add redirect for user
* Add redirect for orgs
* Add user redirect test
* Appease linter
* Add comment to DeleteUserRedirect function
* Fix locale changes
* Fix GetUserByParams
* Fix orgAssignment
* Remove debug logging
* Add redirect prompt
* Dont Export DeleteUserRedirect & only use it within a session
* Unexport newUserRedirect
* cleanup
* Fix & Dedub API code
* Format Template
* Add Migration & rm dublicat
* Refactor: unexport newRepoRedirect() & rm dedub del exec
* if this fails we'll need to re-rename the user directory
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v167.go | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index f62bba2a71..3227f6f754 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -279,6 +279,8 @@ var migrations = []Migration{ NewMigration("Convert hook task type from char(16) to varchar(16) and trim the column", convertHookTaskTypeToVarcharAndTrim), // v166 -> v167 NewMigration("Where Password is Valid with Empty String delete it", recalculateUserEmptyPWD), + // v167 -> v168 + NewMigration("Add user redirect", addUserRedirect), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v167.go b/models/migrations/v167.go new file mode 100644 index 0000000000..fd91f226ab --- /dev/null +++ b/models/migrations/v167.go @@ -0,0 +1,24 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "fmt" + + "xorm.io/xorm" +) + +func addUserRedirect(x *xorm.Engine) (err error) { + type UserRedirect struct { + ID int64 `xorm:"pk autoincr"` + LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` + RedirectUserID int64 + } + + if err := x.Sync2(new(UserRedirect)); err != nil { + return fmt.Errorf("Sync2: %v", err) + } + return nil +} |