From 00dc35e2de02e558dcdbd3911ce3d9b27fddf421 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 23 Jan 2021 12:33:03 +0100 Subject: [PATCH] Fix migration v141 (#14387) (#14388) * Fix mig 141 * temporary fix dump --- models/migrations/v141.go | 2 +- models/models.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/models/migrations/v141.go b/models/migrations/v141.go index b5824ecd48..ab05698b8c 100644 --- a/models/migrations/v141.go +++ b/models/migrations/v141.go @@ -12,7 +12,7 @@ import ( func addKeepActivityPrivateUserColumn(x *xorm.Engine) error { type User struct { - KeepActivityPrivate bool + KeepActivityPrivate bool `xorm:"NOT NULL DEFAULT false"` } if err := x.Sync2(new(User)); err != nil { diff --git a/models/models.go b/models/models.go index f12a4e8b30..4e3d1b8ff6 100644 --- a/models/models.go +++ b/models/models.go @@ -15,12 +15,14 @@ import ( "code.gitea.io/gitea/modules/setting" - // Needed for the MySQL driver - _ "github.com/go-sql-driver/mysql" + "xorm.io/builder" "xorm.io/xorm" "xorm.io/xorm/names" "xorm.io/xorm/schemas" + // Needed for the MySQL driver + _ "github.com/go-sql-driver/mysql" + // Needed for the Postgresql driver _ "github.com/lib/pq" @@ -312,6 +314,13 @@ func DumpDatabase(filePath string, dbType string) error { tbs = append(tbs, t) } + // temporary fix for v1.13.x (https://github.com/go-gitea/gitea/issues/14069) + if _, err := x.Where(builder.IsNull{"keep_activity_private"}). + Cols("keep_activity_private"). + Update(User{KeepActivityPrivate: false}); err != nil { + return err + } + type Version struct { ID int64 `xorm:"pk autoincr"` Version int64