From 9750a23dbe0e018baa127dfdfa18b1b60b49e479 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 30 Jun 2020 11:29:47 +0200 Subject: [PATCH] Make the db timezone migration mysql compatible --- pkg/migration/20200621214452.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/migration/20200621214452.go b/pkg/migration/20200621214452.go index 194931804..b0dc7f4c4 100644 --- a/pkg/migration/20200621214452.go +++ b/pkg/migration/20200621214452.go @@ -649,7 +649,12 @@ create unique index UQE_users_namespace_id } case schemas.MYSQL: 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;", // #nosec "UPDATE " + table + " SET " + colTmp + " = IF(" + colOld + " = 0, NULL, FROM_UNIXTIME(" + colOld + "));",