Skip to content

Commit

Permalink
Dev Porting updated installation sql files and upgrade procs from stable
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@10586 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jul 25, 2011
1 parent df3c3c2 commit 14a7318
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 31 deletions.
2 changes: 1 addition & 1 deletion admin/install/create-mssql.sql
Expand Up @@ -447,7 +447,7 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '146');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '147');
INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname');


Expand Down
2 changes: 1 addition & 1 deletion admin/install/create-mssqlnative.sql
Expand Up @@ -459,7 +459,7 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '146');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '147');
INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname');


Expand Down
2 changes: 1 addition & 1 deletion admin/install/create-mysql.sql
Expand Up @@ -434,7 +434,7 @@ create index `parent_qid_idx` on `prefix_questions` (`parent_qid`);
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '146');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '147');
INSERT INTO `prefix_settings_global` VALUES ('SessionName', '$sessionname');


Expand Down
2 changes: 1 addition & 1 deletion admin/install/create-postgres.sql
Expand Up @@ -459,7 +459,7 @@ create index parent_qid_idx on prefix_questions (parent_qid);
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '146');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '147');
INSERT INTO prefix_settings_global VALUES ('SessionName', '$sessionname');


Expand Down
11 changes: 6 additions & 5 deletions admin/update/updater.php
Expand Up @@ -20,7 +20,7 @@

ob_start();
switch ($subaction)
{
{
case 'step2':
case 'step3':
case 'step4':
Expand All @@ -29,7 +29,7 @@
default:
$updatefunction = 'UpdateStep1';
RunUpdaterUpdate();
}
}

$buffer = $updatefunction();
if ($buffer) echo $buffer;
Expand Down Expand Up @@ -540,13 +540,14 @@ function UpdateStep4()
@unlink($tempdir.'/update.zip');
}
elseif($error=='') {
$body=''; $full_body='';
$body='';
$pFile = fopen($tempdir.'/update.zip', 'w');
for(;;){
$error = $http->ReadReplyBody($body,100000);
if($error != "" || strlen($body)==0) break;
$full_body .= $body;
fwrite($pFile, $body);
}
file_put_contents($tempdir.'/update.zip',$full_body);
fclose($pFile);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions admin/update/upgrade-all.php
Expand Up @@ -21,12 +21,12 @@ function db_upgrade_all($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $dbprefix, $usertemplaterootdir, $standardtemplaterootdir, $clang;
echo str_pad($clang->gT('The LimeSurvey database is being upgraded').' ('.date('Y-m-d H:i:s').')',14096).". Please be patient...<br /><br />\n";
echo str_pad($clang->gT('The LimeSurvey database is being upgraded').' ('.date('Y-m-d H:i:s').')',14096).".". $clang->gT('Please be patient...')."<br /><br />\n";

if ($oldversion < 143)
{
// Move all user templates to the new user template directory
echo "Moving user templates to new location at {$usertemplaterootdir}...<br />";
echo sprintf($clang->gT("Moving user templates to new location at %s..."),$usertemplaterootdir)."<br />";
$myDirectory = opendir($standardtemplaterootdir);
$aFailedTemplates=array();
// get each entry
Expand Down
26 changes: 21 additions & 5 deletions admin/update/upgrade-mssql.php
Expand Up @@ -20,7 +20,7 @@
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $dbprefix;
global $modifyoutput, $dbprefix, $clang;
if ($oldversion < 111) {

// Language upgrades from version 110 to 111 since the language names did change
Expand Down Expand Up @@ -452,6 +452,8 @@ function db_upgrade($oldversion) {
//Add index to questions table to speed up subquestions
modify_database("", "create index [parent_qid] on [prefix_questions] ([parent_qid])"); echo $modifyoutput; flush();ob_flush();

modify_database("","UPDATE prefix_surveys set [private]='N' where [private] is NULL;"); echo $modifyoutput; flush();ob_flush();

modify_database("","EXEC sp_rename 'prefix_surveys.private','anonymized'"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE [prefix_surveys] ALTER COLUMN [anonymized] char(1) NOT NULL;"); echo $modifyoutput; flush();ob_flush();
mssql_drop_constraint('anonymized','surveys');
Expand All @@ -470,13 +472,18 @@ function db_upgrade($oldversion) {


}
if ($oldversion < 146)
if ($oldversion < 146) //Modify surveys table
{
upgrade_timing_tables146();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}
if ($oldversion < 147)
{
modify_database("", "ALTER TABLE [prefix_users] ADD templateeditormode VARCHAR(7) NOT NULL default 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "ALTER TABLE [prefix_users] ADD questionselectormode VARCHAR(7) NOT NULL default 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='147' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}
echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
echo '<br /><br />'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'<br />';
return true;
}

Expand Down Expand Up @@ -562,7 +569,7 @@ function upgrade_token_tables145()
global $modifyoutput, $dbprefix, $connect;
$surveyidquery = db_select_tables_like($dbprefix."tokens%");
$surveyidresult = db_execute_num($surveyidquery);
$tokentables=$connect->MetaTables('TABLES',false,$dbprefix."tokens%");
$tokentables=$connect->MetaTables('TABLES',false, $dbprefix."tokens%");
foreach ($tokentables as $sv) {
modify_database("","ALTER TABLE ".$sv." ADD [usesleft] int NOT NULL DEFAULT '1'"); echo $modifyoutput; flush();ob_flush();
modify_database("","UPDATE ".$sv." SET usesleft=0 WHERE completed<>'N'"); echo $modifyoutput; flush();ob_flush();
Expand Down Expand Up @@ -802,3 +809,12 @@ function upgrade_tables143()
}

}

function upgrade_timing_tables146()
{
global $modifyoutput,$dbprefix, $connect;
$aTimingTables=$connect->MetaTables('TABLES',false, "%timings");
foreach ($aTimingTables as $sTable) {
modify_database("","EXEC sp_rename '{$sTable}.interviewTime','interviewtime'"); echo $modifyoutput; flush(); ob_flush();
}
}
25 changes: 21 additions & 4 deletions admin/update/upgrade-mssqlnative.php
Expand Up @@ -20,7 +20,7 @@
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $dbprefix;
global $modifyoutput, $dbprefix, $clang;
if ($oldversion < 111) {

// Language upgrades from version 110 to 111 since the language names did change
Expand Down Expand Up @@ -452,6 +452,8 @@ function db_upgrade($oldversion) {
//Add index to questions table to speed up subquestions
modify_database("", "create index [parent_qid] on [prefix_questions] ([parent_qid])"); echo $modifyoutput; flush();ob_flush();

modify_database("","UPDATE prefix_surveys set [private]='N' where [private] is NULL;"); echo $modifyoutput; flush();ob_flush();

modify_database("","EXEC sp_rename 'prefix_surveys.private','anonymized'"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE [prefix_surveys] ALTER COLUMN [anonymized] char(1) NOT NULL;"); echo $modifyoutput; flush();ob_flush();
mssql_drop_constraint('anonymized','surveys');
Expand All @@ -469,13 +471,19 @@ function db_upgrade($oldversion) {


}
if ($oldversion < 146)
if ($oldversion < 146) //Modify surveys table
{
upgrade_timing_tables146();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}

if ($oldversion < 147)
{
modify_database("", "ALTER TABLE [prefix_users] ADD templateeditormode VARCHAR( 7 ) NOT NULL default 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "ALTER TABLE [prefix_users] ADD questionselectormode VARCHAR( 7 ) NOT NULL default 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE [prefix_settings_global] SET stg_value='147' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}
echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
echo '<br /><br />'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'<br />';
return true;
}

Expand Down Expand Up @@ -801,3 +809,12 @@ function upgrade_tables143()
}

}

function upgrade_timing_tables146()
{
global $modifyoutput,$dbprefix, $connect;
$aTimingTables=$connect->MetaTables('TABLES',false, "%timings");
foreach ($aTimingTables as $sTable) {
modify_database("","EXEC sp_rename '{$sTable}.interviewTime','interviewtime'"); echo $modifyoutput; flush(); ob_flush();
}
}
26 changes: 21 additions & 5 deletions admin/update/upgrade-mysql.php
Expand Up @@ -20,7 +20,7 @@
function db_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput, $databasename, $databasetabletype, $connect;
global $modifyoutput, $databasename, $databasetabletype, $connect, $clang;
if ($oldversion < 111) {
// Language upgrades from version 110 to 111 since the language names did change

Expand Down Expand Up @@ -443,6 +443,7 @@ function db_upgrade($oldversion) {
modify_database("", "ALTER TABLE `prefix_surveys` DROP COLUMN `notification`"); echo $modifyoutput; flush();ob_flush();

modify_database("","ALTER TABLE `prefix_conditions` CHANGE `method` `method` CHAR( 5 ) NOT NULL default '';"); echo $modifyoutput; flush();ob_flush();
modify_database("","UPDATE `prefix_surveys` set `private`='N' where `private` is NULL;"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE `prefix_surveys` CHANGE `private` `anonymized` char(1) collate utf8_unicode_ci NOT NULL default 'N';"); echo $modifyoutput; flush();ob_flush();


Expand Down Expand Up @@ -575,13 +576,19 @@ function db_upgrade($oldversion) {
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='145' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}

if ($oldversion < 146)
if ($oldversion < 146) //Modify surveys table
{
upgrade_timing_tables146();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}

if ($oldversion < 147)
{
modify_database("", "ALTER TABLE `prefix_users` ADD `templateeditormode` VARCHAR( 7 )NOT NULL DEFAULT 'default' AFTER `htmleditormode`"); echo $modifyoutput; flush();ob_flush();
modify_database("", "ALTER TABLE `prefix_users` ADD `questionselectormode` VARCHAR( 7 )NOT NULL DEFAULT 'default' AFTER `templateeditormode`"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='147' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}
echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
echo '<br /><br />'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'<br />';
return true;
}

Expand Down Expand Up @@ -938,6 +945,15 @@ function upgrade_tables143()
}
}
closedir($handle);
}
}

}

function upgrade_timing_tables146()
{
global $modifyoutput,$dbprefix, $connect;
$aTimingTables=$connect->MetaTables('TABLES',false, "%timings");
foreach ($aTimingTables as $sTable) {
modify_database("","ALTER TABLE {$sTable} CHANGE `interviewTime` `interviewtime` DOUBLE NULL default 0;"); echo $modifyoutput; flush();ob_flush();
}
}
27 changes: 22 additions & 5 deletions admin/update/upgrade-postgres.php
Expand Up @@ -18,7 +18,7 @@
// For this there will be a settings table which holds the last time the database was upgraded

function db_upgrade($oldversion) {
global $modifyoutput, $databasename, $databasetabletype;
global $modifyoutput, $databasename, $databasetabletype, $clang;


if ($oldversion < 127) {
Expand Down Expand Up @@ -283,6 +283,7 @@ function db_upgrade($oldversion) {

modify_database("","ALTER TABLE prefix_conditions ALTER COLUMN method TYPE CHAR(5)"); echo $modifyoutput; flush();ob_flush();

modify_database("","UPDATE prefix_surveys set private='N' where private is NULL;"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE prefix_surveys RENAME COLUMN private TO anonymized;"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE prefix_surveys ALTER COLUMN anonymized TYPE char(1);"); echo $modifyoutput; flush();ob_flush();
modify_database("","ALTER TABLE prefix_surveys ALTER COLUMN anonymized SET DEFAULT 'N';"); echo $modifyoutput; flush();ob_flush();
Expand All @@ -297,14 +298,21 @@ function db_upgrade($oldversion) {
upgrade_token_tables145();
modify_database("", "UPDATE prefix_settings_global SET stg_value='145' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}
if ($oldversion < 146)

if ($oldversion < 146) //Modify surveys table
{
upgrade_timing_tables146();
modify_database("", "UPDATE prefix_settings_global SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}

if ($oldversion < 147)
{
modify_database("", "ALTER TABLE prefix_users ADD templateeditormode character varying(7) NOT NULL DEFAULT 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "ALTER TABLE prefix_users ADD questionselectormode character varying(7) NOT NULL DEFAULT 'default'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE prefix_settings_global SET stg_value='146' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
modify_database("", "UPDATE prefix_settings_global SET stg_value='147' WHERE stg_name='DBVersion'"); echo $modifyoutput; flush();ob_flush();
}

echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
echo '<br /><br />'.sprintf($clang->gT('Database update finished (%s)'),date('Y-m-d H:i:s')).'<br />';
return true;
}

Expand Down Expand Up @@ -555,6 +563,15 @@ function upgrade_tables143()
}
}
closedir($handle);
}
}

}

function upgrade_timing_tables146()
{
global $modifyoutput,$dbprefix, $connect;
$aTimingTables=$connect->MetaTables('TABLES',false, "%timings");
foreach ($aTimingTables as $sTable) {
modify_database("","ALTER TABLE {$sTable} RENAME COLUMN \"interviewTime\" TO interviewtime;"); echo $modifyoutput; flush();ob_flush();
}
}
2 changes: 1 addition & 1 deletion version.php
@@ -1,7 +1,7 @@
<?php

$versionnumber = "1.92dev";
$dbversionnumber = 146;
$dbversionnumber = 147;
$buildnumber = '';

?>

0 comments on commit 14a7318

Please sign in to comment.