Make the db timezone migration mysql compatible

This commit is contained in:
kolaente 2020-06-30 11:29:47 +02:00
parent 1c93aab7e0
commit 9750a23dbe
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -649,7 +649,12 @@ create unique index UQE_users_namespace_id
} }
case schemas.MYSQL: case schemas.MYSQL:
sql = []string{ sql = []string{
"ALTER TABLE " + table + " DROP COLUMN IF EXISTS " + colTmp + ";", // mysql does not support the IF EXISTS part of the following statement. To not break
// compatibility with mysql over mariadb, we're not using it.
// The statement is probably useless anyway since its only purpose is to clean up old tables
// which may be leftovers from a previously failed migration. However, since the whole thing
// is wrapped in sessions, this is extremely unlikely to happen anyway.
//"ALTER TABLE " + table + " DROP COLUMN IF EXISTS " + colTmp + ";",
"ALTER TABLE " + table + " ADD COLUMN " + colTmp + " DATETIME NULL;", "ALTER TABLE " + table + " ADD COLUMN " + colTmp + " DATETIME NULL;",
// #nosec // #nosec
"UPDATE " + table + " SET " + colTmp + " = IF(" + colOld + " = 0, NULL, FROM_UNIXTIME(" + colOld + "));", "UPDATE " + table + " SET " + colTmp + " = IF(" + colOld + " = 0, NULL, FROM_UNIXTIME(" + colOld + "));",