Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/LimeSurvey/LimeSurvey in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
LouisGac committed Jun 20, 2017
2 parents 984652c + 92a0d54 commit b900673
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@

$config['versionnumber'] = '3.0.0-alpha'; //The current version of this branch
$config['masterversion'] = '2.62.2'; //The current masters version merged into this branch
$config['dbversionnumber'] = 263;
$config['dbversionnumber'] = 292;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '2647';
Expand Down
59 changes: 29 additions & 30 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -27,7 +27,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
* @link https://manual.limesurvey.org/Database_versioning for explanations
* @var array $aCriticalDBVersions An array of cricital database version.
*/
$aCriticalDBVersions=array(261);
$aCriticalDBVersions=array();
$aAllUpdates=range($iOldDBVersion+1,Yii::app()->getConfig('dbversionnumber'));
// If trying to update silenty check if it is really possible
if ($bSilent && ($iOldDBVersion<258 || count(array_intersect($aCriticalDBVersions,$aAllUpdates))>0))
Expand Down Expand Up @@ -1554,12 +1554,12 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oDB->createCommand()->createTable('{{notifications}}', array(
'id' => 'pk',
'entity' => 'string(15) not null',
'entity_id' => 'int not null',
'entity_id' => 'integer not null',
'title' => 'string not null', // varchar(255) in postgres
'message' => 'text not null',
'status' => 'string(15) default \'new\'',
'importance' => 'int default 1',
'display_class' => 'string(31) default \'default\'',
'status' => "string(15) not null default 'new' ",
'importance' => 'integer default 1',
'display_class' => "string(31) default \'default\'",
'created' => 'datetime not null',
'first_read' => 'datetime null'
));
Expand All @@ -1575,25 +1575,39 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>260),"stg_name='DBVersion'");
$oTransaction->commit();
}

if ($iOldDBVersion < 261) {
$oTransaction = $oDB->beginTransaction();
/*
* The hash value of a notification is used to calculate uniqueness.
* @since 2016-08-10
* @author Olle Haerstedt
*/
if ($iOldDBVersion < 261) {
$oTransaction = $oDB->beginTransaction();
addColumn('{{notifications}}', 'hash', 'string(64)');
$oDB->createCommand()->createIndex('notif_hash_index', '{{notifications}}', 'hash', false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>261),"stg_name='DBVersion'");
$oTransaction->commit();
}

if ($iOldDBVersion < 262) {
$oTransaction = $oDB->beginTransaction();
alterColumn('{{settings_global}}','stg_value',"text",false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>262),"stg_name='DBVersion'");
$oTransaction->commit();
}

if ($iOldDBVersion < 263) {
$oTransaction = $oDB->beginTransaction();
// Dummy version update for hash column in installation SQL.
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>263),"stg_name='DBVersion'");
$oTransaction->commit();
}

/**
* Add seed column in all active survey tables
* Might take time to execute
* @since 2016-09-01
*/
if ($iOldDBVersion < 262) {
if ($iOldDBVersion < 290) {

$oTransaction = $oDB->beginTransaction();

Expand Down Expand Up @@ -1629,29 +1643,29 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
}
}
}
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>262),"stg_name='DBVersion'");
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>290),"stg_name='DBVersion'");
$oTransaction->commit();
}

/**
* Plugin JSON config file
* @since 2016-08-22
*/
if ($iOldDBVersion < 263)
if ($iOldDBVersion < 291)
{
$oTransaction = $oDB->beginTransaction();

addColumn('{{plugins}}', 'version', 'string(32)');

$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>263),"stg_name='DBVersion'");
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>291),"stg_name='DBVersion'");
$oTransaction->commit();
}

/**
* User settings table
* @since 2016-08-29
*/
if ($iOldDBVersion < 264) {
if ($iOldDBVersion < 292) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->createTable('{{settings_user}}', array(
'uid' => 'integer NOT NULL',
Expand All @@ -1661,24 +1675,9 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
'stg_value' => 'text',
'PRIMARY KEY (uid, entity, entity_id, stg_name)'
));
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>264),"stg_name='DBVersion'");
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>292),"stg_name='DBVersion'");
$oTransaction->commit();
}

// Inform superadmin about update
// TODO: DON'T FORGET TO UPDATE THIS
$superadmins = User::model()->getSuperAdmins();
Notification::broadcast(array(
'title' => gT('Database update'),
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, '264') // <--- UPDATE THIS
), $superadmins);

// Activate schema caching
$oDB->schemaCachingDuration=3600;
// Load all tables of the application in the schema
$oDB->schema->getTables();
// clear the cache of all loaded tables
$oDB->schema->refresh();
}
catch(Exception $e)
{
Expand Down Expand Up @@ -1706,7 +1705,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$superadmins = User::model()->getSuperAdmins();
Notification::broadcast(array(
'title' => gT('Database update'),
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, '261')
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, '292')
), $superadmins);
fixLanguageConsistencyAllSurveys();
Yii::app()->setConfig('Updating',false);
Expand Down
2 changes: 1 addition & 1 deletion installer/sql/create-mssql.sql
Expand Up @@ -625,4 +625,4 @@ CREATE TABLE prefix_settings_user (
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '264');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '292');
2 changes: 1 addition & 1 deletion installer/sql/create-mysql.sql
Expand Up @@ -631,4 +631,4 @@ CREATE TABLE IF NOT EXISTS `prefix_settings_user` (
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '264');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '292');
2 changes: 1 addition & 1 deletion installer/sql/create-pgsql.sql
Expand Up @@ -634,4 +634,4 @@ CREATE TABLE prefix_settings_user (
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '264');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '292');

0 comments on commit b900673

Please sign in to comment.