diff --git a/pkg/migration/migration.go b/pkg/migration/migration.go index 9f6711209..19c9d632e 100644 --- a/pkg/migration/migration.go +++ b/pkg/migration/migration.go @@ -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) }