This commit is contained in:
parent
d3cf78cb8d
commit
46003efc50
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user