Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 7, 2012
2 parents 1ff5213 + 239562b commit ad4af30
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.00+";
$config['dbversionnumber'] = 163;
$config['dbversionnumber'] = 164;
$config['buildnumber'] = '';
$config['updatable'] = true;

Expand Down
37 changes: 37 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -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 '<br /><br />'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'<br /><br />';
}
Expand Down Expand Up @@ -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)');
}
}
}
}
2 changes: 1 addition & 1 deletion installer/sql/create-mssql.sql
Expand Up @@ -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');
2 changes: 1 addition & 1 deletion installer/sql/create-mysql.sql
Expand Up @@ -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');
2 changes: 1 addition & 1 deletion installer/sql/create-pgsql.sql
Expand Up @@ -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');

0 comments on commit ad4af30

Please sign in to comment.