Skip to content

Commit

Permalink
Dev: added survey group table
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 24, 2017
1 parent bc9d4bf commit f0198e0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
53 changes: 53 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -316,6 +316,17 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>305),"stg_name='DBVersion'");
}

/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 305) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables305($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>305),"stg_name='DBVersion'");
}

}
catch(Exception $e)
{
Expand Down Expand Up @@ -450,6 +461,48 @@ function createSurveyMenuTable293($oDB) {
}
}

/**
* @param $oDB
* @return void
*/
function upgradeTemplateTables305($oDB)
{
// Drop the old survey rights table.
if (tableExists('{surveys_groups}')) {
$oDB->createCommand()->dropTable('{{surveys_groups}}');
}


// Create templates table
$oDB->createCommand()->createTable('{{surveys_groups}}', array(
'gsid' => 'pk',
'name' => 'string(45) NOT NULL',
'title' => 'string(100) DEFAULT NULL',
'description' => 'text DEFAULT NULL',
'order' => 'int(11) NOT NULL',
'owner_uid' => 'int(11) DEFAULT NULL',
'parent_id' => 'int(11) DEFAULT NULL',
'created' => 'DATETIME',
'modified' => 'DATETIME',
'created_by' => 'int(11) NOT NULL'
));

// Add default template
$date = date("Y-m-d H:i:s");
$oDB->createCommand()->insert('{{surveys_groups}}', array(
'name' => 'default',
'title' => 'Default Survey Group',
'description' => 'LimeSurvey core default survey group',
'order' => '0',
'owner_uid' => '1',
'created' => $date,
'modified' => $date,
'created_by' => '1'
));

$oDB->createCommand()->addColumn('{{surveys}}','gsid',"int(11) DEFAULT 1");
}

/**
* @param $oDB
* @return void
Expand Down
30 changes: 28 additions & 2 deletions installer/sql/create-mysql.sql
Expand Up @@ -463,10 +463,10 @@ CREATE TABLE `prefix_surveys` (
`alloweditaftercompletion` varchar(1) default 'N',
`googleanalyticsstyle` varchar(1) DEFAULT NULL,
`googleanalyticsapikey` VARCHAR(25) DEFAULT NULL,
`gsid` int(11) DEFAULT '1'
PRIMARY KEY (`sid`)
) ENGINE=MYISAM CHARACTER SET utf8mb4 ;


--
-- Table structure for table surveys_languagesettings
--
Expand Down Expand Up @@ -775,7 +775,33 @@ INSERT INTO `prefix_template_configuration` VALUES
(3,'material',NULL,NULL,NULL,'{"add": ["css/template.css", "css/bootstrap-material-design.css", "css/ripples.min.css"]}','{"add": ["scripts/template.js", "scripts/material.js", "scripts/ripples.min.js"]}','{"add":"css/print_template.css",}','{"ajaxmode":"on","brandlogo":"on", "animatebody":"on","bodyanimation":"fadeInRight","animatequestion":"off","questionanimation":"flipInX","animatealert":"off","alertanimation":"shake"}','bootstrap','{"replace": [["css/bootstrap.css","css/bootstrap.css"]]}','','','','');


-- -----------------------------------------------------
-- Table `prefix_surveys_groups`
-- -----------------------------------------------------
CREATE TABLE `prefix_surveys_groups` (
`gsid` int(11) NOT NULL,
`name` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`title` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` text COLLATE utf8mb4_unicode_ci,
`order` int(11) NOT NULL,
`owner_uid` int(11) DEFAULT NULL,
`parent_id` int(11) DEFAULT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
`created_by` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `prefix_surveys_groups`
ADD PRIMARY KEY (`gsid`);

ALTER TABLE `prefix_surveys_groups`
MODIFY `gsid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

INSERT INTO `prefix_surveys_groups` (`gsid`, `name`, `title`, `description`, `order`, `owner_uid`, `parent_id`, `created`, `modified`, `created_by`) VALUES
(1, 'default', 'Default Survey Group', 'LimeSurvey core default survey group', 0, 1, NULL, '2017-07-20 17:09:30', '2017-07-20 17:09:30', 1);


--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '301');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '305');

0 comments on commit f0198e0

Please sign in to comment.