Skip to content

Commit

Permalink
Fixed Possible failure on upgrade due to missing survey_links table
Browse files Browse the repository at this point in the history
  • Loading branch information
mennodekker committed Dec 24, 2012
1 parent 11e2b61 commit c9e9c98
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion application/helpers/update/updatedb_helper.php
Expand Up @@ -78,7 +78,7 @@ function db_upgrade_all($oldversion) {
Yii::app()->db->createCommand()->alterColumn('{{saved_control}}','email',"{$sVarchar}(320) NOT NULL");
Yii::app()->db->createCommand()->alterColumn('{{surveys}}','adminemail',"{$sVarchar}(320) NOT NULL");
Yii::app()->db->createCommand()->alterColumn('{{users}}','email',"{$sVarchar}(320) NOT NULL");
Yii::app()->db->createCommand()->insert('{{settings_global}}',array('stg_name'=>'SessionName','stg_value'=>randomChars(64,'ABCDEFGHIJKLMNOPQRSTUVWXYZ!"§$%&/()=?´`+*~#",;.:abcdefghijklmnopqrstuvwxyz123456789')));

This comment has been minimized.

Copy link
@mennodekker

mennodekker Dec 24, 2012

Author Contributor

Didn't see this but got warning on not safe utf-8 opening of the file. Maybe the first ans last char should be removed?

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Dec 24, 2012

Collaborator

It's § and ´ regarding the diff. And i see this one time too ago. Think i removed it .....

Yii::app()->db->createCommand()->insert('{{settings_global}}',array('stg_name'=>'SessionName','stg_value'=>randomChars(64,'ABCDEFGHIJKLMNOPQRSTUVWXYZ!"$%&/()=?`+*~#",;.:abcdefghijklmnopqrstuvwxyz123456789')));
Yii::app()->db->createCommand()->update('{{settings_global}}',array('stg_value'=>114),"stg_name='DBVersion'");
}

Expand Down Expand Up @@ -914,6 +914,18 @@ function db_upgrade_all($oldversion) {
alterColumn('{{survey_permissions}}','sid','integer',false);
alterColumn('{{survey_permissions}}','uid','integer',false);
alterColumn('{{users}}','htmleditormode',"{$sVarchar}(7)",true,'default');

// Sometimes the survey_links table was deleted before this step, if so
// we recreate it (copied from line 663)
if (!tableExists('{survey_links}')) {
createTable('{{survey_links}}',array(
'participant_id' => $sVarchar.'(50) NOT NULL',
'token_id' => 'integer NOT NULL',
'survey_id' => 'integer NOT NULL',
'date_created' => 'datetime NOT NULL'
));
addPrimaryKey('survey_links', array('participant_id','token_id','survey_id'));
}
alterColumn('{{survey_links}}','date_created',"datetime",true);
alterColumn('{{saved_control}}','identifier',"text",false);
alterColumn('{{saved_control}}','email',"{$sVarchar}(320)");
Expand Down

0 comments on commit c9e9c98

Please sign in to comment.