Maybe this is somehow solvable with regex....
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
22e2a72fb9
commit
3b138190eb
|
@ -17,13 +17,16 @@
|
||||||
package migration
|
package migration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"code.vikunja.io/api/pkg/db"
|
"code.vikunja.io/api/pkg/db"
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
"code.vikunja.io/api/pkg/models"
|
"code.vikunja.io/api/pkg/models"
|
||||||
|
"github.com/go-xorm/core"
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"sort"
|
"sort"
|
||||||
"src.techknowlogick.com/xormigrate"
|
"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.
|
// 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,
|
// 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
|
// we need to sort them to ensure that they are in order
|
||||||
sort.Slice(migrations, func(i, j int) bool {
|
sort.Slice(migrations, func(i, j int) bool {
|
||||||
|
@ -50,7 +62,7 @@ func Migrate(x *xorm.Engine) {
|
||||||
m := xormigrate.New(x, migrations)
|
m := xormigrate.New(x, migrations)
|
||||||
m.NewLogger(log.GetLogWriter("database"))
|
m.NewLogger(log.GetLogWriter("database"))
|
||||||
m.InitSchema(initSchema)
|
m.InitSchema(initSchema)
|
||||||
err := m.Migrate()
|
err = m.Migrate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log.Criticalf("Migration failed: %v", err)
|
log.Log.Criticalf("Migration failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user