summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-03-10 23:43:51 +0800
committerGitHub <noreply@github.com>2017-03-10 23:43:51 +0800
commit74cde12677bc548487ed1caf192eb19b0b7cf99c (patch)
tree08dd8fca3b12c447833a13f0aefd87e9f4d90431
parentf5476bdbb182835996e4e7269df64bf50dfc367b (diff)
downloadgitea-74cde12677bc548487ed1caf192eb19b0b7cf99c.tar.gz
gitea-74cde12677bc548487ed1caf192eb19b0b7cf99c.zip
Fix upgrade failed after ever rollback (#1194)
* fix upgrade failed after rollback * fix upgrade failed after rollback * fix possible upgrade twice fail after rollback
-rw-r--r--models/migrations/v16.go6
-rw-r--r--models/migrations/v19.go10
-rw-r--r--models/migrations/v20.go4
3 files changed, 17 insertions, 3 deletions
diff --git a/models/migrations/v16.go b/models/migrations/v16.go
index 47292c41e2..12cad46d09 100644
--- a/models/migrations/v16.go
+++ b/models/migrations/v16.go
@@ -59,6 +59,12 @@ func addUnitsToTables(x *xorm.Engine) error {
}
var repoUnit RepoUnit
+ if exist, err := sess.IsTableExist(&repoUnit); err != nil {
+ return fmt.Errorf("IsExist RepoUnit: %v", err)
+ } else if exist {
+ return nil
+ }
+
if err := sess.CreateTable(&repoUnit); err != nil {
return fmt.Errorf("CreateTable RepoUnit: %v", err)
}
diff --git a/models/migrations/v19.go b/models/migrations/v19.go
index 6e0dbedaa3..0edeb3e92e 100644
--- a/models/migrations/v19.go
+++ b/models/migrations/v19.go
@@ -60,8 +60,14 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
oldHookPath := filepath.Join(hookDir, hookName)
newHookPath := filepath.Join(hookDir, hookName+".d", "gitea")
- if err = os.MkdirAll(filepath.Join(hookDir, hookName+".d"), os.ModePerm); err != nil {
- return fmt.Errorf("create hooks dir '%s': %v", filepath.Join(hookDir, hookName+".d"), err)
+ customHooksDir := filepath.Join(hookDir, hookName+".d")
+ // if it's exist, that means you have upgraded ever
+ if com.IsExist(customHooksDir) {
+ continue
+ }
+
+ if err = os.MkdirAll(customHooksDir, os.ModePerm); err != nil {
+ return fmt.Errorf("create hooks dir '%s': %v", customHooksDir, err)
}
// WARNING: Old server-side hooks will be moved to sub directory with the same name
diff --git a/models/migrations/v20.go b/models/migrations/v20.go
index 45d7e49ca8..982914a06e 100644
--- a/models/migrations/v20.go
+++ b/models/migrations/v20.go
@@ -13,6 +13,7 @@ import (
"path/filepath"
"strconv"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/go-xorm/xorm"
@@ -40,7 +41,8 @@ func useNewNameAvatars(x *xorm.Engine) error {
for _, name := range names {
userID, err := strconv.ParseInt(name, 10, 64)
if err != nil {
- return err
+ log.Warn("ignore avatar %s rename: %v", name, err)
+ continue
}
var user User