diff --git a/application/config/version.php b/application/config/version.php index eebd630d8c4..2a89bf1fe59 100644 --- a/application/config/version.php +++ b/application/config/version.php @@ -13,7 +13,7 @@ */ $config['versionnumber'] = "2.00+"; -$config['dbversionnumber'] = 163; +$config['dbversionnumber'] = 164; $config['buildnumber'] = ''; $config['updatable'] = true; diff --git a/application/helpers/update/updatedb_helper.php b/application/helpers/update/updatedb_helper.php index 5b5584d5b21..32ba26cf843 100644 --- a/application/helpers/update/updatedb_helper.php +++ b/application/helpers/update/updatedb_helper.php @@ -1024,6 +1024,14 @@ function db_upgrade_all($oldversion) { $replacedTemplate=replaceTemplateJS(); } + + if ($oldversion < 164) + { + // fix survey tables for missing or incorrect token field + upgradeSurveyTables164(); + + // Not updating settings table as upgrade process takes care of that step now + } fixLanguageConsistencyAllSurveys(); echo '

'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'

'; } @@ -1825,3 +1833,32 @@ function replaceTemplateJS(){ return $countstartpage; } } + +/** + * Make sure all active tables have the right sized token field + * + * During a small period in the 2.0 cycle some survey tables got no + * token field or a token field that was too small. This patch makes + * sure all surveys that are not anonymous have a token field with the + * right size + * + * @return void + */ +function upgradeSurveyTables164() +{ + $surveyidquery = "SELECT sid FROM {{surveys}} WHERE active='Y' and anonymized='N'"; + $surveyidresult = Yii::app()->db->createCommand($surveyidquery)->queryAll(); + if (!$surveyidresult) { + return "Database Error"; + } else { + foreach ( $surveyidresult as $sv ) + { + $token = Survey_dynamic::model($sv['sid'])->getTableSchema()->getColumn('token'); + if (is_null($token)) { + addColumn('{{survey_'.$sv['sid'].'}}','token','varchar(36)'); + } elseif ($token->size < 36) { + alterColumn('{{survey_'.$sv['sid'].'}}','token','varchar(36)'); + } + } + } +} diff --git a/installer/sql/create-mssql.sql b/installer/sql/create-mssql.sql index d08c084ff9b..890b4bde39c 100644 --- a/installer/sql/create-mssql.sql +++ b/installer/sql/create-mssql.sql @@ -551,4 +551,4 @@ create index [labels_code_idx] on [prefix_labels] ([code]); -- -- Version Info -- -INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '163'); +INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '164'); diff --git a/installer/sql/create-mysql.sql b/installer/sql/create-mysql.sql index 20d00a0066e..98209280874 100644 --- a/installer/sql/create-mysql.sql +++ b/installer/sql/create-mysql.sql @@ -556,4 +556,4 @@ create index `parent_qid_idx` on `prefix_questions` (`parent_qid`); -- -- Version Info -- -INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '163'); +INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '164'); diff --git a/installer/sql/create-pgsql.sql b/installer/sql/create-pgsql.sql index 5ea19a72081..e706af7a05c 100644 --- a/installer/sql/create-pgsql.sql +++ b/installer/sql/create-pgsql.sql @@ -562,4 +562,4 @@ create index labels_code_idx on prefix_labels (code); -- -- Version Info -- -INSERT INTO prefix_settings_global VALUES ('DBVersion', '163'); +INSERT INTO prefix_settings_global VALUES ('DBVersion', '164');