Skip to content

Commit

Permalink
Changed feature #9206: Extended firstname, lastname to 150 characters…
Browse files Browse the repository at this point in the history
… and email fields to 254 characters on token tables and participant database to match width

Changed feature: Token attributes are now of type text
  • Loading branch information
c-schmitz committed Sep 9, 2014
1 parent 21a9f27 commit 9e2c376
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.06";
$config['dbversionnumber'] = 177;
$config['dbversionnumber'] = 178;
$config['buildnumber'] = '';
$config['updatable'] = true;

Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/token_helper.php
Expand Up @@ -44,7 +44,7 @@ function createTokenTable($iSurveyID, $aAttributeFields=array())
);
foreach ($aAttributeFields as $sAttributeField)
{
$fields[$sAttributeField]='string';
$fields[$sAttributeField]='text';
}
try{
$sTableName="{{tokens_".intval($iSurveyID)."}}";
Expand Down
39 changes: 39 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1252,6 +1252,14 @@ function db_upgrade_all($iOldDBVersion) {
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>177),"stg_name='DBVersion'");
}

if ($iOldDBVersion < 178)
{
upgradeTokenTables178();
alterColumn('{{participants}}', 'email', "{$sVarchar}(254)", false);
alterColumn('{{participants}}', 'firstname', "{$sVarchar}(150)", false);
alterColumn('{{participants}}', 'lastname', "{$sVarchar}(150)", false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>178),"stg_name='DBVersion'");
}

$oTransaction->commit();
// Activate schema caching
Expand Down Expand Up @@ -1279,6 +1287,37 @@ function db_upgrade_all($iOldDBVersion) {
}


function upgradeTokenTables178()
{
$sVarchar = Yii::app()->getConfig('varchar');
$oSchema=Yii::app()->db->schema;
$sDBDriverName=setsDBDriverName();
if($sDBDriverName=='mssql') $sSubstringCommand='substring'; else $sSubstringCommand='substr';

$surveyidresult = dbGetTablesLike("tokens%");
if (!$surveyidresult) {return "Database Error";}
else
{
foreach ( $surveyidresult as $sv )
{
$sTableName=reset($sv);
$oSchema=$oSchema->getTable($sTableName);
foreach ($oSchema->columnNames as $sColumnName)
{
if (strpos($sColumnName,'attribute_')===0)
{
alterColumn($sTableName, $sColumnName, "text");
}
}
Yii::app()->db->createCommand("UPDATE {$sTableName} set email={$sSubstringCommand}(email,0,254)")->execute();
alterColumn($sTableName, 'email', "{$sVarchar}(254)");
alterColumn($sTableName, 'firstname', "{$sVarchar}(150)");
alterColumn($sTableName, 'lastname', "{$sVarchar}(150)");
}
}
}


function upgradeSurveys177()
{
$sSurveyQuery = "SELECT * FROM {{surveys_languagesettings}}";
Expand Down
6 changes: 3 additions & 3 deletions installer/sql/create-mssql.sql
Expand Up @@ -193,8 +193,8 @@ PRIMARY KEY ([participant_id],[share_uid])
--
CREATE TABLE [prefix_participants] (
[participant_id] varchar(50) NOT NULL,
[firstname] varchar(40) NULL,
[lastname] varchar(40) NULL,
[firstname] varchar(150) NULL,
[lastname] varchar(150) NULL,
[email] varchar(254) NULL,
[language] varchar(40) NULL,
[blacklisted] varchar(1) NOT NULL,
Expand Down Expand Up @@ -566,4 +566,4 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]);
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '177');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '178');
6 changes: 3 additions & 3 deletions installer/sql/create-mysql.sql
Expand Up @@ -193,8 +193,8 @@ CREATE TABLE `prefix_participant_shares` (
--
CREATE TABLE `prefix_participants` (
`participant_id` varchar(50) NOT NULL,
`firstname` varchar(40) DEFAULT NULL,
`lastname` varchar(40) DEFAULT NULL,
`firstname` varchar(150) DEFAULT NULL,
`lastname` varchar(150) DEFAULT NULL,
`email` varchar(254) DEFAULT NULL,
`language` varchar(40) DEFAULT NULL,
`blacklisted` varchar(1) NOT NULL,
Expand Down Expand Up @@ -571,4 +571,4 @@ create index `parent_qid_idx` on `prefix_questions` (`parent_qid`);
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '177');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '178');
6 changes: 3 additions & 3 deletions installer/sql/create-pgsql.sql
Expand Up @@ -199,8 +199,8 @@ CREATE TABLE prefix_participant_shares (
--
CREATE TABLE prefix_participants (
"participant_id" character varying(50) PRIMARY KEY NOT NULL,
"firstname" character varying(40),
"lastname" character varying(40),
"firstname" character varying(150),
"lastname" character varying(150),
"email" character varying(254),
"language" character varying(40),
"blacklisted" character varying(1) NOT NULL,
Expand Down Expand Up @@ -576,4 +576,4 @@ create unique index permissions_idx2 ON prefix_permissions (entity_id, entity, u
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '177');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '178');

0 comments on commit 9e2c376

Please sign in to comment.