forked from vikunja/vikunja
Fix sql statement for mysql
This commit is contained in:
parent
d3cf78cb8d
commit
46003efc50
|
@ -45,16 +45,17 @@ ALTER TABLE ` + table + ` DROP COLUMN ` + column + `_ts;
|
||||||
case schemas.MYSQL:
|
case schemas.MYSQL:
|
||||||
sql = `
|
sql = `
|
||||||
ALTER TABLE ` + table + ` DROP COLUMN IF EXISTS ` + column + `_ts;
|
ALTER TABLE ` + table + ` DROP COLUMN IF EXISTS ` + column + `_ts;
|
||||||
ALTER TABLE ` + table + ` ADD COLUMN ` + column + `_ts DATETIME;
|
ALTER TABLE ` + table + ` ADD ` + column + `_ts DATETIME null;
|
||||||
UPDATE ` + table + ` SET ` + column + `_ts = TIMESTAMP 'epoch' + ` + column + ` * INTERVAL '1 second';
|
UPDATE ` + table + ` SET ` + column + `_ts = FROM_UNIXTIME(` + column + `);
|
||||||
ALTER TABLE ` + table + ` ALTER COLUMN ` + column + ` TYPE USING ` + column + `_ts;
|
ALTER TABLE ` + table + ` DROP COLUMN ` + column + `;
|
||||||
ALTER TABLE ` + table + ` DROP COLUMN ` + column + `_ts;
|
ALTER TABLE ` + table + ` CHANGE ` + column + `_ts ` + column + ` DATETIME NOT NULL;
|
||||||
`
|
`
|
||||||
case schemas.SQLITE:
|
case schemas.SQLITE:
|
||||||
// welp
|
// welp
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported dbms: %s", tx.Dialect().URI().DBType)
|
return fmt.Errorf("unsupported dbms: %s", tx.Dialect().URI().DBType)
|
||||||
}
|
}
|
||||||
|
|
||||||
sess := tx.NewSession()
|
sess := tx.NewSession()
|
||||||
if err := sess.Begin(); err != nil {
|
if err := sess.Begin(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user