summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-01-29 19:30:43 +0100
committerGitHub <noreply@github.com>2021-01-29 19:30:43 +0100
commit0e0424c8ecaf6fa3cdd1fcfc154f188014c63dd8 (patch)
tree30faffc8d529ef405c9a8de25fec066ea2d393f8 /models
parent05365816ab28bd23267feec8b3cd9d8721bc0dbe (diff)
downloadgitea-0e0424c8ecaf6fa3cdd1fcfc154f188014c63dd8.tar.gz
gitea-0e0424c8ecaf6fa3cdd1fcfc154f188014c63dd8.zip
Add Doctor FixWrongUserType (#14522)
* Add Doctor FixWrongUserType * use NoAutoTime
Diffstat (limited to 'models')
-rw-r--r--models/consistency.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/models/consistency.go b/models/consistency.go
index fbb99ca80c..f689261a55 100644
--- a/models/consistency.go
+++ b/models/consistency.go
@@ -291,7 +291,17 @@ func CountNullArchivedRepository() (int64, error) {
// FixNullArchivedRepository sets is_archived to false where it is null
func FixNullArchivedRepository() (int64, error) {
- return x.Where(builder.IsNull{"is_archived"}).Cols("is_archived").Update(&Repository{
+ return x.Where(builder.IsNull{"is_archived"}).Cols("is_archived").NoAutoTime().Update(&Repository{
IsArchived: false,
})
}
+
+// CountWrongUserType count OrgUser who have wrong type
+func CountWrongUserType() (int64, error) {
+ return x.Where(builder.Eq{"type": 0}.And(builder.Neq{"num_teams": 0})).Count(new(User))
+}
+
+// FixWrongUserType fix OrgUser who have wrong type
+func FixWrongUserType() (int64, error) {
+ return x.Where(builder.Eq{"type": 0}.And(builder.Neq{"num_teams": 0})).Cols("type").NoAutoTime().Update(&User{Type: 1})
+}