Maybe this is somehow solvable with regex....
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2019-03-27 08:27:47 +01:00
parent 22e2a72fb9
commit 3b138190eb
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 13 additions and 1 deletions

View File

@ -17,13 +17,16 @@
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.
@ -41,6 +44,15 @@ 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 {
@ -50,7 +62,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)
}