diff options
author | Peter Smit <peter@smitmail.eu> | 2015-01-22 14:56:50 +0200 |
---|---|---|
committer | Peter Smit <peter@smitmail.eu> | 2015-01-22 14:56:50 +0200 |
commit | 2a70d6b7235a124027ebc446d8559b4596cb6dcd (patch) | |
tree | 0b58d7ef0ec2f07e258d079e045b10fafc7b0bd7 /models/migrations | |
parent | bb103e87239e6789b42eb4ceaab45f6cf49adb2e (diff) | |
download | gitea-2a70d6b7235a124027ebc446d8559b4596cb6dcd.tar.gz gitea-2a70d6b7235a124027ebc446d8559b4596cb6dcd.zip |
Clean up migrations code
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 0b52708172..e51bc3c876 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -2,6 +2,7 @@ package migrations import ( "errors" + "github.com/go-xorm/xorm" ) @@ -9,7 +10,7 @@ type migration func(*xorm.Engine) error // The version table. Should have only one row with id==1 type Version struct { - Id int64 `xorm:"pk"` + Id int64 Version int64 } @@ -25,9 +26,10 @@ func Migrate(x *xorm.Engine) error { has, err := x.Get(currentVersion) if err != nil { return err - } - if !has { - _, err = x.InsertOne(currentVersion) + } else if !has { + if _, err = x.InsertOne(currentVersion); err != nil { + return err + } } v := currentVersion.Version |