From c5cd863f15adbca72b1a6ee27e05071bf75659b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Wed, 14 Dec 2022 16:34:00 +0100 Subject: [PATCH] Use database() value for column existing detection [MAILPOET-4916] --- mailpoet/lib/Migrator/Migration.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mailpoet/lib/Migrator/Migration.php b/mailpoet/lib/Migrator/Migration.php index 8ba300d25e..efa5ff4ec8 100644 --- a/mailpoet/lib/Migrator/Migration.php +++ b/mailpoet/lib/Migrator/Migration.php @@ -43,10 +43,12 @@ abstract class Migration { } protected function columnExists(string $tableName, string $columnName): bool { + // We had a problem with the dbName value in ENV for some customers, because it doesn't match DB name in information schema. + // So we decided to use the DATABASE() value instead. return $this->connection->executeQuery(" SELECT 1 FROM information_schema.columns - WHERE table_schema = ? + WHERE table_schema = COALESCE(DATABASE(), ?) AND table_name = ? AND column_name = ? ", [Env::$dbName, $tableName, $columnName])->fetchOne() !== false;