diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-11-02 16:54:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 16:54:36 +0800 |
commit | e72acd5e5b2d043fcf0a0182a1eedaed8120c155 (patch) | |
tree | 77e4c341bef6450e5dfa7a1f61c9693527a133d0 /models/migrations/v1_7 | |
parent | 4827f42f56bcc70d40e073a8502930d9cce39798 (diff) | |
download | gitea-e72acd5e5b2d043fcf0a0182a1eedaed8120c155.tar.gz gitea-e72acd5e5b2d043fcf0a0182a1eedaed8120c155.zip |
Split migrations folder (#21549)
There are too many files in `models/migrations` folder so that I split
them into sub folders.
Diffstat (limited to 'models/migrations/v1_7')
-rw-r--r-- | models/migrations/v1_7/v73.go | 19 | ||||
-rw-r--r-- | models/migrations/v1_7/v74.go | 16 | ||||
-rw-r--r-- | models/migrations/v1_7/v75.go | 33 |
3 files changed, 68 insertions, 0 deletions
diff --git a/models/migrations/v1_7/v73.go b/models/migrations/v1_7/v73.go new file mode 100644 index 0000000000..aa2cbba88a --- /dev/null +++ b/models/migrations/v1_7/v73.go @@ -0,0 +1,19 @@ +// Copyright 2018 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 v1_7 // nolint + +import ( + "xorm.io/xorm" +) + +func AddMustChangePassword(x *xorm.Engine) error { + // User see models/user.go + type User struct { + ID int64 `xorm:"pk autoincr"` + MustChangePassword bool `xorm:"NOT NULL DEFAULT false"` + } + + return x.Sync2(new(User)) +} diff --git a/models/migrations/v1_7/v74.go b/models/migrations/v1_7/v74.go new file mode 100644 index 0000000000..3694d68d31 --- /dev/null +++ b/models/migrations/v1_7/v74.go @@ -0,0 +1,16 @@ +// Copyright 2018 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 v1_7 // nolint + +import "xorm.io/xorm" + +func AddApprovalWhitelistsToProtectedBranches(x *xorm.Engine) error { + type ProtectedBranch struct { + ApprovalsWhitelistUserIDs []int64 `xorm:"JSON TEXT"` + ApprovalsWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` + RequiredApprovals int64 `xorm:"NOT NULL DEFAULT 0"` + } + return x.Sync2(new(ProtectedBranch)) +} diff --git a/models/migrations/v1_7/v75.go b/models/migrations/v1_7/v75.go new file mode 100644 index 0000000000..df26667351 --- /dev/null +++ b/models/migrations/v1_7/v75.go @@ -0,0 +1,33 @@ +// Copyright 2018 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 v1_7 // nolint + +import ( + "xorm.io/builder" + "xorm.io/xorm" +) + +func ClearNonusedData(x *xorm.Engine) error { + condDelete := func(colName string) builder.Cond { + return builder.NotIn(colName, builder.Select("id").From("`user`")) + } + + if _, err := x.Exec(builder.Delete(condDelete("uid")).From("team_user")); err != nil { + return err + } + + if _, err := x.Exec(builder.Delete(condDelete("user_id")).From("collaboration")); err != nil { + return err + } + + if _, err := x.Exec(builder.Delete(condDelete("user_id")).From("stopwatch")); err != nil { + return err + } + + if _, err := x.Exec(builder.Delete(condDelete("owner_id")).From("gpg_key")); err != nil { + return err + } + return nil +} |