diff --git a/pkg/migration/20200621214452.go b/pkg/migration/20200621214452.go index fb1219abb2..30d0ffc99f 100644 --- a/pkg/migration/20200621214452.go +++ b/pkg/migration/20200621214452.go @@ -45,16 +45,17 @@ ALTER TABLE ` + table + ` DROP COLUMN ` + column + `_ts; case schemas.MYSQL: sql = ` ALTER TABLE ` + table + ` DROP COLUMN IF EXISTS ` + column + `_ts; -ALTER TABLE ` + table + ` ADD COLUMN ` + column + `_ts DATETIME; -UPDATE ` + table + ` SET ` + column + `_ts = TIMESTAMP 'epoch' + ` + column + ` * INTERVAL '1 second'; -ALTER TABLE ` + table + ` ALTER COLUMN ` + column + ` TYPE USING ` + column + `_ts; -ALTER TABLE ` + table + ` DROP COLUMN ` + column + `_ts; +ALTER TABLE ` + table + ` ADD ` + column + `_ts DATETIME null; +UPDATE ` + table + ` SET ` + column + `_ts = FROM_UNIXTIME(` + column + `); +ALTER TABLE ` + table + ` DROP COLUMN ` + column + `; +ALTER TABLE ` + table + ` CHANGE ` + column + `_ts ` + column + ` DATETIME NOT NULL; ` case schemas.SQLITE: // welp default: return fmt.Errorf("unsupported dbms: %s", tx.Dialect().URI().DBType) } + sess := tx.NewSession() if err := sess.Begin(); err != nil { return err