From 3089628c128b37c8921cdc8c38c74cee0c32b8ca Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Thu, 22 Oct 2020 13:17:15 +0200 Subject: [PATCH] Fixed issue: Create token table on Postgres throws index error, if done repeatedly --- application/helpers/update/updatedb_helper.php | 4 ++-- application/models/Token.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/helpers/update/updatedb_helper.php b/application/helpers/update/updatedb_helper.php index 69dc8cc1902..b63ff6638ca 100644 --- a/application/helpers/update/updatedb_helper.php +++ b/application/helpers/update/updatedb_helper.php @@ -2472,8 +2472,8 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false) $oDB->createCommand()->createIndex('idx_email', $sTableName, 'email(30)', false); break; case 'pgsql': - $oDB->createCommand()->createIndex('idx_email', $sTableName, 'email', false); - break; + $oDB->createCommand()->createIndex('idx_email_'.substr($sTableName,7).'_'.rand(1, 50000), $sTableName, 'email', false); + break; // MSSQL does not support indexes on text fields so no dice } } catch (Exception $e) { rollBackToTransactionBookmark(); } diff --git a/application/models/Token.php b/application/models/Token.php index eb1c3ee2f8d..b322f49218a 100644 --- a/application/models/Token.php +++ b/application/models/Token.php @@ -203,7 +203,7 @@ public static function createTable($surveyId, array $extraFields = array()) $db->createCommand()->createIndex('idx_email', $sTableName, 'email(30)', false); break; case 'pgsql': - $db->createCommand()->createIndex('idx_email_'.$surveyId_.rand(1, 50000), $sTableName, 'email', false); + $db->createCommand()->createIndex('idx_email_'.$surveyId.'_'.rand(1, 50000), $sTableName, 'email', false); break; }