Skip to content

Commit

Permalink
Fixed issue: Create token table on Postgres throws index error, if do…
Browse files Browse the repository at this point in the history
…ne repeatedly
  • Loading branch information
c-schmitz committed Oct 22, 2020
1 parent 37e9f26 commit 3089628
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -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(); }
Expand Down
2 changes: 1 addition & 1 deletion application/models/Token.php
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3089628

Please sign in to comment.