"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "models/migrations/migrations.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

migrations.go  (gitea-1.13.1):migrations.go  (gitea-1.13.2)
skipping to change at line 19 skipping to change at line 19
"fmt" "fmt"
"os" "os"
"reflect" "reflect"
"regexp" "regexp"
"strings" "strings"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"xorm.io/xorm" "xorm.io/xorm"
"xorm.io/xorm/names"
) )
const minDBVersion = 70 // Gitea 1.5.3 const minDBVersion = 70 // Gitea 1.5.3
// Migration describes on migration from lower version to high version // Migration describes on migration from lower version to high version
type Migration interface { type Migration interface {
Description() string Description() string
Migrate(*xorm.Engine) error Migrate(*xorm.Engine) error
} }
skipping to change at line 299 skipping to change at line 300
if currentDB != expected { if currentDB != expected {
return fmt.Errorf(`Current database version %d is not equal to th e expected version %d. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version`, currentDB, expected) return fmt.Errorf(`Current database version %d is not equal to th e expected version %d. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version`, currentDB, expected)
} }
return nil return nil
} }
// Migrate database to current version // Migrate database to current version
func Migrate(x *xorm.Engine) error { func Migrate(x *xorm.Engine) error {
// Set a new clean the default mapper to GonicMapper as that is the defau
lt for Gitea.
x.SetMapper(names.GonicMapper{})
if err := x.Sync(new(Version)); err != nil { if err := x.Sync(new(Version)); err != nil {
return fmt.Errorf("sync: %v", err) return fmt.Errorf("sync: %v", err)
} }
currentVersion := &Version{ID: 1} currentVersion := &Version{ID: 1}
has, err := x.Get(currentVersion) has, err := x.Get(currentVersion)
if err != nil { if err != nil {
return fmt.Errorf("get: %v", err) return fmt.Errorf("get: %v", err)
} else if !has { } else if !has {
// If the version record does not exist we think // If the version record does not exist we think
skipping to change at line 337 skipping to change at line 340
msg := fmt.Sprintf("Downgrading database version from '%d' to '%d ' is not supported and may result in loss of data integrity.\nIf you really know what you're doing, execute `UPDATE version SET version=%d WHERE id=1;`\n", msg := fmt.Sprintf("Downgrading database version from '%d' to '%d ' is not supported and may result in loss of data integrity.\nIf you really know what you're doing, execute `UPDATE version SET version=%d WHERE id=1;`\n",
v, minDBVersion+len(migrations), minDBVersion+len(migrati ons)) v, minDBVersion+len(migrations), minDBVersion+len(migrati ons))
fmt.Fprint(os.Stderr, msg) fmt.Fprint(os.Stderr, msg)
log.Fatal(msg) log.Fatal(msg)
return nil return nil
} }
// Migrate // Migrate
for i, m := range migrations[v-minDBVersion:] { for i, m := range migrations[v-minDBVersion:] {
log.Info("Migration[%d]: %s", v+int64(i), m.Description()) log.Info("Migration[%d]: %s", v+int64(i), m.Description())
// Reset the mapper between each migration - migrations are not s
upposed to depend on each other
x.SetMapper(names.GonicMapper{})
if err = m.Migrate(x); err != nil { if err = m.Migrate(x); err != nil {
return fmt.Errorf("do migrate: %v", err) return fmt.Errorf("do migrate: %v", err)
} }
currentVersion.Version = v + int64(i) + 1 currentVersion.Version = v + int64(i) + 1
if _, err = x.ID(1).Update(currentVersion); err != nil { if _, err = x.ID(1).Update(currentVersion); err != nil {
return err return err
} }
} }
return nil return nil
} }
 End of changes. 3 change blocks. 
0 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)