DB Migrations #67
|
@ -17,16 +17,13 @@
|
|||
package migration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/models"
|
||||
"github.com/go-xorm/core"
|
||||
"github.com/go-xorm/xorm"
|
||||
"github.com/spf13/viper"
|
||||
"sort"
|
||||
"src.techknowlogick.com/xormigrate"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// You can get the id string for new migrations by running `date +%Y%m%d%H%M%S` on a unix system.
|
||||
|
@ -44,15 +41,6 @@ func Migrate(x *xorm.Engine) {
|
|||
}
|
||||
}
|
||||
|
||||
info := x.TableInfo(models.ListTask{}).Table
|
||||
buf := &bytes.Buffer{}
|
||||
err := x.DumpTables([]*core.Table{info}, buf, core.SQLITE)
|
||||
colToRemove := "reminders_unix"
|
||||
dump := buf.String()
|
||||
dumpremoved := strings.ReplaceAll(dump, "`"+colToRemove+"` TEXT NULL, ", "")
|
||||
dumpremoved = strings.ReplaceAll(dumpremoved, "`"+colToRemove+"` TEXT NULL, ", "")
|
||||
// (, )?`updated`([A-Z ])*,?
|
||||
|
||||
// Because init() does not guarantee the order in which these are added to the slice,
|
||||
// we need to sort them to ensure that they are in order
|
||||
sort.Slice(migrations, func(i, j int) bool {
|
||||
|
@ -62,7 +50,7 @@ func Migrate(x *xorm.Engine) {
|
|||
m := xormigrate.New(x, migrations)
|
||||
m.NewLogger(log.GetLogWriter("database"))
|
||||
m.InitSchema(initSchema)
|
||||
err = m.Migrate()
|
||||
err := m.Migrate()
|
||||
if err != nil {
|
||||
log.Log.Criticalf("Migration failed: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue