Added initschema
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2019-03-26 08:03:38 +01:00
parent cb208e6101
commit 6b48bcf9c2
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 7 additions and 21 deletions

View File

@ -19,7 +19,6 @@ package migration
import (
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/models"
"github.com/go-xorm/xorm"
"sort"
"src.techknowlogick.com/xormigrate"
@ -29,26 +28,6 @@ import (
var migrations []*xormigrate.Migration
var tables []interface{}
func init() {
tables = append(tables,
new(models.User),
new(models.List),
new(models.ListTask),
new(models.Team),
new(models.TeamMember),
new(models.TeamList),
new(models.TeamNamespace),
new(models.Namespace),
new(models.ListUser),
new(models.NamespaceUser),
new(models.ListTaskAssginee),
new(models.Label),
new(models.LabelTask),
)
}
func Migrate(x *xorm.Engine) {
// Get our own xorm engine if we don't have one
if x == nil {
@ -68,6 +47,7 @@ func Migrate(x *xorm.Engine) {
m := xormigrate.New(x, migrations)
m.NewLogger(log.GetLogWriter("database"))
m.InitSchema(initSchema)
err := m.Migrate()
if err != nil {
log.Log.Criticalf("Migration failed: %v", err)
@ -138,3 +118,9 @@ func Migrate(x *xorm.Engine) {
Table team_members has column updated but struct has not related field
*/
}
func initSchema(tx *xorm.Engine) error {
return tx.Sync2(
db.GetTables(),
)
}