First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,246 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7.alpha1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Base class for incremental upgrades
*/
class CRM_Upgrade_Incremental_Base {
const BATCH_SIZE = 5000;
/**
* Verify DB state.
*
* @param $errors
*
* @return bool
*/
public function verifyPreDBstate(&$errors) {
return TRUE;
}
/**
* Compute any messages which should be displayed before upgrade.
*
* Note: This function is called iteratively for each upcoming
* revision to the database.
*
* @param $preUpgradeMessage
* @param string $rev
* a version number, e.g. '4.8.alpha1', '4.8.beta3', '4.8.0'.
* @param null $currentVer
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
}
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
}
/**
* (Queue Task Callback)
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $rev
*
* @return bool
*/
public static function runSql(CRM_Queue_TaskContext $ctx, $rev) {
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
return TRUE;
}
/**
* Syntactic sugar for adding a task.
*
* Task is (a) in this class and (b) has a high priority.
*
* After passing the $funcName, you can also pass parameters that will go to
* the function. Note that all params must be serializable.
*
* @param string $title
* @param string $funcName
*/
protected function addTask($title, $funcName) {
$queue = CRM_Queue_Service::singleton()->load(array(
'type' => 'Sql',
'name' => CRM_Upgrade_Form::QUEUE_NAME,
));
$args = func_get_args();
$title = array_shift($args);
$funcName = array_shift($args);
$task = new CRM_Queue_Task(
array(get_class($this), $funcName),
$args,
$title
);
$queue->createItem($task, array('weight' => -1));
}
/**
* Remove a payment processor if not in use
*
* @param CRM_Queue_TaskContext $ctx
* @param string $name
* @return bool
* @throws \CiviCRM_API3_Exception
*/
public static function removePaymentProcessorType(CRM_Queue_TaskContext $ctx, $name) {
$processors = civicrm_api3('PaymentProcessor', 'getcount', array('payment_processor_type_id' => $name));
if (empty($processors['result'])) {
$result = civicrm_api3('PaymentProcessorType', 'get', array(
'name' => $name,
'return' => 'id',
));
if (!empty($result['id'])) {
civicrm_api3('PaymentProcessorType', 'delete', array('id' => $result['id']));
}
}
return TRUE;
}
/**
* @param string $table_name
* @param string $constraint_name
* @return bool
*/
public static function checkFKExists($table_name, $constraint_name) {
return CRM_Core_BAO_SchemaHandler::checkFKExists($table_name, $constraint_name);
}
/**
* Add a column to a table if it doesn't already exist
*
* @param CRM_Queue_TaskContext $ctx
* @param string $table
* @param string $column
* @param string $properties
* @param bool $localizable is this a field that should be localized
* @return bool
*/
public static function addColumn($ctx, $table, $column, $properties, $localizable = FALSE) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$queries = array();
if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, $column)) {
if ($domain->locales) {
if ($localizable) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
foreach ($locales as $locale) {
if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, "{$column}_{$locale}")) {
$queries[] = "ALTER TABLE `$table` ADD COLUMN `{$column}_{$locale}` $properties";
}
}
}
else {
$queries[] = "ALTER TABLE `$table` ADD COLUMN `$column` $properties";
}
}
else {
$queries[] = "ALTER TABLE `$table` ADD COLUMN `$column` $properties";
}
foreach ($queries as $query) {
CRM_Core_DAO::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE);
}
}
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE);
}
return TRUE;
}
/**
* Drop a column from a table if it exist.
*
* @param CRM_Queue_TaskContext $ctx
* @param string $table
* @param string $column
* @return bool
*/
public static function dropColumn($ctx, $table, $column) {
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists($table, $column)) {
CRM_Core_DAO::executeQuery("ALTER TABLE `$table` DROP COLUMN `$column`",
array(), TRUE, NULL, FALSE, FALSE);
}
return TRUE;
}
/**
* Add a index to a table column.
*
* @param CRM_Queue_TaskContext $ctx
* @param string $table
* @param string|array $column
* @return bool
*/
public static function addIndex($ctx, $table, $column) {
$tables = array($table => (array) $column);
CRM_Core_BAO_SchemaHandler::createIndexes($tables);
return TRUE;
}
/**
* Drop a index from a table if it exist.
*
* @param CRM_Queue_TaskContext $ctx
* @param string $table
* @param string $indexName
* @return bool
*/
public static function dropIndex($ctx, $table, $indexName) {
CRM_Core_BAO_SchemaHandler::dropIndexIfExists($table, $indexName);
return TRUE;
}
/**
* Rebuild Multilingual Schema.
* @param CRM_Queue_TaskContext $ctx
* @return bool
*/
public static function rebuildMultilingalSchema($ctx) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales);
}
return TRUE;
}
}

View file

@ -0,0 +1,194 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* This class contains generic upgrade logic which runs regardless of version.
*/
class CRM_Upgrade_Incremental_General {
/**
* The recommended PHP version.
*/
const RECOMMENDED_PHP_VER = '7.0';
/**
* The previous recommended PHP version.
*/
const MIN_RECOMMENDED_PHP_VER = '5.6';
/**
* The minimum PHP version required to install Civi.
*
* @see install/index.php
*/
const MIN_INSTALL_PHP_VER = '5.4';
/**
* Compute any messages which should be displayed before upgrade.
*
* @param string $preUpgradeMessage
* alterable.
* @param $currentVer
* @param $latestVer
*/
public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
$dateFormat = Civi::Settings()->get('dateformatshortdate');
if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) {
$preUpgradeMessage .= '<p>';
$preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2 or above. We recommend PHP version %3.', array(
1 => $latestVer,
2 => self::MIN_RECOMMENDED_PHP_VER,
3 => self::RECOMMENDED_PHP_VER,
));
$preUpgradeMessage .= '</p>';
}
// http://issues.civicrm.org/jira/browse/CRM-13572
// Depending on how the code was upgraded, some sites may still have copies of old
// source files left behind. This is often a forgivable offense, but it's quite
// dangerous for CIVI-SA-2013-001.
global $civicrm_root;
$ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php";
if (file_exists($ofcFile)) {
if (@unlink($ofcFile)) {
$preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array(
1 => $ofcFile,
));
}
else {
$preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array(
1 => $ofcFile,
));
}
}
if (Civi::settings()->get('enable_innodb_fts')) {
// The FTS indexing feature dynamically manipulates the schema which could
// cause conflicts with other layers that manipulate the schema. The
// simplest thing is to turn it off and back on.
// It may not always be necessary to do this -- but I doubt we're going to test
// systematically in future releases. When it is necessary, one could probably
// ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences
// after the upgrade. But that's speculative. For now, we'll leave this
// advanced feature in the hands of the sysadmin.
$preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => System Settings => Miscellaneous".');
}
$ftAclSetting = Civi::settings()->get('acl_financial_type');
$financialAclExtension = civicrm_api3('extension', 'get', array('key' => 'biz.jmaconsulting.financialaclreport'));
if ($ftAclSetting && (($financialAclExtension['count'] == 1 && $financialAclExtension['status'] != 'Installed') || $financialAclExtension['count'] !== 1)) {
$preUpgradeMessage .= '<br />' . ts('CiviCRM will in the future require the extension %1 for CiviCRM Reports to work correctly with the Financial Type ACLs. The extension can be downloaded <a href="%2">here</a>', array(
1 => 'biz.jmaconsulting.financialaclreport',
2 => 'https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport',
));
}
}
/**
* @param $message
* @param $latestVer
* @param $currentVer
*/
public static function checkMessageTemplate(&$message, $latestVer, $currentVer) {
$sql = "SELECT orig.workflow_id as workflow_id,
orig.msg_title as title
FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON (
diverted.workflow_id = orig.workflow_id AND
orig.is_reserved = 1 AND (
diverted.msg_subject != orig.msg_subject OR
diverted.msg_text != orig.msg_text OR
diverted.msg_html != orig.msg_html
)
)";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$workflows[$dao->workflow_id] = $dao->title;
}
if (empty($workflows)) {
return;
}
$html = NULL;
$pathName = dirname(dirname(__FILE__));
$flag = FALSE;
foreach ($workflows as $workflow => $title) {
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue',
$workflow,
'name',
'id'
);
// check if file exists locally
$textFileName = implode(DIRECTORY_SEPARATOR,
array(
$pathName,
"{$latestVer}.msg_template",
'message_templates',
"{$name}_text.tpl",
)
);
$htmlFileName = implode(DIRECTORY_SEPARATOR,
array(
$pathName,
"{$latestVer}.msg_template",
'message_templates',
"{$name}_html.tpl",
)
);
if (file_exists($textFileName) ||
file_exists($htmlFileName)
) {
$flag = TRUE;
$html .= "<li>{$title}</li>";
}
}
if ($flag == TRUE) {
$html = "<ul>" . $html . "<ul>";
$message .= '<br />' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. <a href='%1' style='color:white; text-decoration:underline; font-weight:bold;' target='_blank'>Click here</a> for detailed instructions. %2", array(
1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates',
2 => $html,
));
}
}
}

View file

@ -0,0 +1,373 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Upgrade logic for 4.5
*/
class CRM_Upgrade_Incremental_php_FourFive extends CRM_Upgrade_Incremental_Base {
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '4.5.alpha1') {
$postUpgradeMessage .= '<br /><br />' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: <ul><li>Contributions - Receipt (off-line)</li><li>Contributions - Receipt (on-line)</li><li>Contributions - Recurring Start and End Notification</li><li>Contributions - Recurring Updates</li><li>Memberships - Receipt (on-line)</li><li>Memberships - Signup and Renewal Receipts (off-line)</li><li>Pledges - Acknowledgement</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages). (<a href="%1">learn more...</a>)', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Updating+System+Workflow+Message+Templates+after+Upgrades+-+method+1+-+kdiff'));
$postUpgradeMessage .= '<br /><br />' . ts('This release allows you to view and edit multiple-record custom field sets in a table format which will be more usable in some cases. You can try out the format by navigating to Administer > Custom Data & Screens > Custom Fields. Click Settings for a custom field set and change Display Style to "Tab with Tables".');
$postUpgradeMessage .= '<br /><br />' . ts('This release changes the way that anonymous event registrations match participants with existing contacts. By default, all event participants will be matched with existing individuals using the Unsupervised rule, even if multiple registrations with the same email address are allowed. However, you can now select a different matching rule to use for each event. Please review your events to make sure you choose the appropriate matching rule and collect sufficient information for it to match contacts.');
}
if ($rev == '4.5.beta2') {
$postUpgradeMessage .= '<br /><br />' . ts('If you use CiviMail for newsletters or other communications, check out the new sample CiviMail templates which use responsive design to optimize display on mobile devices (Administer > Communications > Message Templates ).');
}
if ($rev == '4.5.1') {
$postUpgradeMessage .= '<br /><br />' . ts('WARNING: If you use CiviCase with v4.5.alpha*, v4.5.beta*, or v4.5.0, it is possible that previous upgrades corrupted some CiviCase metadata. If you have not already done so, please identify any custom field sets, smart groups, or reports which refer to CiviCase and ensure that they are properly configured.');
}
}
/**
* @param $rev
*
* @return bool
*/
public function upgrade_4_5_alpha1($rev) {
// task to process sql
$this->addTask('Migrate honoree information to module_data', 'migrateHonoreeInfo');
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.5.alpha1')), 'runSql', $rev);
$this->addTask('Set default for Individual name fields configuration', 'addNameFieldOptions');
// CRM-14522 - The below schema checking is done as foreign key name
// for pdf_format_id column varies for different databases
// if DB is been into upgrade for 3.4.2 version, it would have pdf_format_id name for FK
// else FK_civicrm_msg_template_pdf_format_id
$config = CRM_Core_Config::singleton();
$dbUf = DB::parseDSN($config->dsn);
$query = "
SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME = 'civicrm_msg_template'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
AND TABLE_SCHEMA = %1
";
$params = array(1 => array($dbUf['database'], 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
if ($dao->fetch()) {
if ($dao->CONSTRAINT_NAME == 'FK_civicrm_msg_template_pdf_format_id' ||
$dao->CONSTRAINT_NAME == 'pdf_format_id'
) {
$sqlDropFK = "ALTER TABLE `civicrm_msg_template`
DROP FOREIGN KEY `{$dao->CONSTRAINT_NAME}`,
DROP KEY `{$dao->CONSTRAINT_NAME}`";
CRM_Core_DAO::executeQuery($sqlDropFK, CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
}
}
return TRUE;
}
/**
* @param $rev
*
* @return bool
*/
public function upgrade_4_5_beta9($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.5.beta9')), 'runSql', $rev);
$entityTable = array(
'Participant' => 'civicrm_participant_payment',
'Contribution' => 'civicrm_contribution',
'Membership' => 'civicrm_membership',
);
foreach ($entityTable as $label => $tableName) {
list($minId, $maxId) = CRM_Core_DAO::executeQuery("SELECT coalesce(min(id),0), coalesce(max(id),0)
FROM {$tableName}")->getDatabaseResult()->fetchRow();
for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = ts("Upgrade DB to 4.5.beta9: Fix line items for {$label} (%1 => %2)", array(
1 => $startId,
2 => $endId,
));
$this->addTask($title, 'task_4_5_0_fixLineItem', $startId, $endId, $label);
}
}
return TRUE;
}
/**
* (Queue Task Callback)
*
* update the line items
*
*
* @param CRM_Queue_TaskContext $ctx
* @param int $startId
* the first/lowest entity ID to convert.
* @param int $endId
* the last/highest entity ID to convert.
* @param
*
* @return bool
*/
public static function task_4_5_0_fixLineItem(CRM_Queue_TaskContext $ctx, $startId, $endId, $entityTable) {
$sqlParams = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
switch ($entityTable) {
case 'Contribution':
// update all the line item entity_table and entity_id with contribution due to bug CRM-15055
CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item li
INNER JOIN civicrm_contribution cc ON cc.id = li.contribution_id
SET entity_id = li.contribution_id, entity_table = 'civicrm_contribution'
WHERE li.contribution_id IS NOT NULL AND li.entity_table <> 'civicrm_participant' AND (cc.id BETWEEN %1 AND %2)", $sqlParams);
// update the civicrm_line_item.contribution_id
CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item li
INNER JOIN civicrm_contribution cc ON cc.id = li.entity_id
SET contribution_id = entity_id
WHERE li.contribution_id IS NULL AND li.entity_table = 'civicrm_contribution' AND (cc.id BETWEEN %1 AND %2)", $sqlParams);
break;
case 'Participant':
// update the civicrm_line_item.contribution_id
CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item li
INNER JOIN civicrm_participant_payment pp ON pp.participant_id = li.entity_id
SET li.contribution_id = pp.contribution_id
WHERE li.entity_table = 'civicrm_participant' AND li.contribution_id IS NULL AND (pp.id BETWEEN %1 AND %2)", $sqlParams);
break;
case 'Membership':
$upgrade = new CRM_Upgrade_Form();
// update the line item of membership
CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item li
INNER JOIN civicrm_membership_payment mp ON mp.contribution_id = li.contribution_id
INNER JOIN civicrm_membership cm ON mp.membership_id = cm.id
INNER JOIN civicrm_price_field_value pv ON pv.id = li.price_field_value_id
SET li.entity_table = 'civicrm_membership', li.entity_id = mp.membership_id
WHERE li.entity_table = 'civicrm_contribution'
AND pv.membership_type_id IS NOT NULL AND cm.membership_type_id = pv.membership_type_id AND (cm.id BETWEEN %1 AND %2)", $sqlParams);
CRM_Core_DAO::executeQuery("UPDATE civicrm_line_item li
INNER JOIN civicrm_membership_payment mp ON mp.contribution_id = li.contribution_id
INNER JOIN civicrm_price_field_value pv ON pv.id = li.price_field_value_id
SET li.entity_table = 'civicrm_membership', li.entity_id = mp.membership_id
WHERE li.entity_table = 'civicrm_contribution'
AND pv.membership_type_id IS NOT NULL AND (mp.membership_id BETWEEN %1 AND %2)", $sqlParams);
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_line_item (entity_table, entity_id, price_field_id, label,
qty, unit_price, line_total, price_field_value_id, financial_type_id)
SELECT 'civicrm_membership', cm.id, cpf.id price_field_id, cpfv.label, 1 as qty, cpfv.amount, cpfv.amount line_total,
cpfv.id price_field_value_id, cpfv.financial_type_id FROM civicrm_membership cm
LEFT JOIN civicrm_membership_payment cmp ON cmp.membership_id = cm.id
INNER JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cm.membership_type_id
INNER JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id
INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id
WHERE cmp.contribution_id IS NULL AND cps.name = 'default_membership_type_amount' AND (cm.id BETWEEN %1 AND %2)", $sqlParams);
break;
}
return TRUE;
}
/**
* Add defaults for the newly introduced name fields configuration in 'contact_edit_options' setting
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool
* TRUE for success
*/
public static function addNameFieldOptions(CRM_Queue_TaskContext $ctx) {
$query = "SELECT `value` FROM `civicrm_setting` WHERE `group_name` = 'CiviCRM Preferences' AND `name` = 'contact_edit_options'";
$dao = CRM_Core_DAO::executeQuery($query);
$dao->fetch();
$oldValue = unserialize($dao->value);
$newValue = $oldValue . '1214151617';
$query = "UPDATE `civicrm_setting` SET `value` = %1 WHERE `group_name` = 'CiviCRM Preferences' AND `name` = 'contact_edit_options'";
$params = array(1 => array(serialize($newValue), 'String'));
CRM_Core_DAO::executeQuery($query, $params);
return TRUE;
}
/**
* Migrate honoree information to uf_join.module_data as honoree columns (text and title) will be dropped
* on DB upgrade
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool
* TRUE for success
*/
public static function migrateHonoreeInfo(CRM_Queue_TaskContext $ctx) {
$query = "ALTER TABLE `civicrm_uf_join`
ADD COLUMN `module_data` longtext COMMENT 'Json serialized array of data used by the ufjoin.module'";
CRM_Core_DAO::executeQuery($query);
$honorTypes = array_keys(CRM_Core_OptionGroup::values('honor_type'));
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'new_individual';
$ufGroupDAO->find(TRUE);
$query = "SELECT * FROM civicrm_contribution_page";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
while ($dao->fetch()) {
$honorParams = array('soft_credit' => array('soft_credit_types' => $honorTypes));
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
foreach ($locales as $locale) {
$honor_block_title = "honor_block_title_{$locale}";
$honor_block_text = "honor_block_text_{$locale}";
$honorParams['soft_credit'] += array(
$locale => array(
'honor_block_title' => $dao->$honor_block_title,
'honor_block_text' => $dao->$honor_block_text,
),
);
}
}
else {
$honorParams['soft_credit'] += array(
'default' => array(
'honor_block_title' => $dao->honor_block_title,
'honor_block_text' => $dao->honor_block_text,
),
);
}
$ufJoinParam = array(
'module' => 'soft_credit',
'entity_table' => 'civicrm_contribution_page',
'is_active' => $dao->honor_block_is_active,
'entity_id' => $dao->id,
'uf_group_id' => $ufGroupDAO->id,
'module_data' => json_encode($honorParams),
);
CRM_Core_BAO_UFJoin::create($ufJoinParam);
}
}
return TRUE;
}
/**
* Upgrade function.
*
* @param string $rev
* @return bool
*/
public function upgrade_4_5_9($rev) {
// Task to process sql.
$this->addTask('Upgrade DB to 4.5.9: Fix saved searches consisting of multi-choice custom field(s)', 'updateSavedSearch');
return TRUE;
}
/**
* Update saved search for multi-select custom fields on DB upgrade
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool TRUE for success
*/
public static function updateSavedSearch(CRM_Queue_TaskContext $ctx) {
$sql = "SELECT id, form_values FROM civicrm_saved_search";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$copy = $formValues = unserialize($dao->form_values);
$update = FALSE;
foreach ($copy as $field => $data_value) {
if (preg_match('/^custom_/', $field) && is_array($data_value) && !array_key_exists("${field}_operator", $formValues)) {
// Now check for CiviCRM_OP_OR as either key or value in the data_value array.
// This is the conclusive evidence of an old-style data format.
if (array_key_exists('CiviCRM_OP_OR', $data_value) || FALSE !== array_search('CiviCRM_OP_OR', $data_value)) {
// We have old style data. Mark this record to be updated.
$update = TRUE;
$op = 'and';
if (!preg_match('/^custom_([0-9]+)/', $field, $matches)) {
// fatal error?
continue;
}
$fieldID = $matches[1];
if (array_key_exists('CiviCRM_OP_OR', $data_value)) {
// This indicates data structure identified by jamie in the form:
// value1 => 1, value2 => , value3 => 1.
$data_value = array_keys($data_value, 1);
// If CiviCRM_OP_OR - change OP from default to OR
if ($data_value['CiviCRM_OP_OR'] == 1) {
$op = 'or';
}
unset($data_value['CiviCRM_OP_OR']);
}
else {
// The value is here, but it is not set as a key.
// This is using the style identified by Monish - the existence of the value
// indicates an OR search and values are set in the form of:
// 0 => value1, 1 => value1, 3 => value2.
$key = array_search('CiviCRM_OP_OR', $data_value);
$op = 'or';
unset($data_value[$key]);
}
//If only Or operator has been chosen, means we need to select all values and
//so to execute OR operation between these values according to new data structure
if (count($data_value) == 0 && $op == 'or') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($fieldID);
foreach ($customOption as $option) {
$data_value[] = CRM_Utils_Array::value('value', $option);
}
}
$formValues[$field] = $data_value;
$formValues["${field}_operator"] = $op;
}
}
}
if ($update) {
$sql = "UPDATE civicrm_saved_search SET form_values = %0 WHERE id = %1";
CRM_Core_DAO::executeQuery($sql,
array(
array(serialize($formValues), 'String'),
array($dao->id, 'Integer'),
)
);
}
}
return TRUE;
}
}

View file

@ -0,0 +1,819 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Upgrade logic for 4.4
*/
class CRM_Upgrade_Incremental_php_FourFour extends CRM_Upgrade_Incremental_Base {
const MAX_WORD_REPLACEMENT_SIZE = 255;
/**
* Compute any messages which should be displayed beforeupgrade.
*
* Note: This function is called iteratively for each upcoming
* revision to the database.
*
* @param $preUpgradeMessage
* @param string $rev
* a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
* @param string $currentVer
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev == '4.4.beta1') {
$apiCalls = self::getConfigArraysAsAPIParams(FALSE);
$oversizedEntries = 0;
foreach ($apiCalls as $params) {
if (!self::isValidWordReplacement($params)) {
$oversizedEntries++;
}
}
if ($oversizedEntries > 0) {
$preUpgradeMessage .= '<br/>' . ts("WARNING: There are %1 word-replacement entries which will not be valid in v4.4+ (eg with over 255 characters). They will be dropped during upgrade. For details, consult the CiviCRM log.", array(
1 => $oversizedEntries,
));
}
}
}
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '4.4.1') {
$config = CRM_Core_Config::singleton();
if (!empty($config->useIDS)) {
$postUpgradeMessage .= '<br />' . ts("The setting to skip IDS check has been removed. Your site has this configured in civicrm.settings.php but it will no longer work. Instead, use the new permission 'skip IDS check' to bypass the IDS system.");
}
}
if ($rev == '4.4.3') {
$postUpgradeMessage .= '<br /><br />' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: <ul><li>Events - Registration Confirmation and Receipt (on-line)</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
}
if ($rev == '4.4.3') {
$query = "SELECT cft.id financial_trxn
FROM civicrm_financial_trxn cft
LEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.financial_trxn_id = cft.id
LEFT JOIN civicrm_contribution cc ON ceft.entity_id = cc.id
WHERE ceft.entity_table = 'civicrm_contribution' AND cft.payment_instrument_id IS NULL;";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
$postUpgradeMessage .= '<br /><br /><strong>' . ts('Your database contains %1 financial transaction records with no payment instrument (Paid By is empty). If you use the Accounting Batches feature this may result in unbalanced transactions. If you do not use this feature, you can ignore the condition (although you will be required to select a Paid By value for new transactions). <a href="%2" target="_blank">You can review steps to correct transactions with missing payment instruments on the wiki.</a>', array(
1 => $dao->N,
2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades',
)) . '</strong>';
}
}
if ($rev == '4.4.6') {
$postUpgradeMessage .= '<br /><br /><strong>' . ts('Your contact image urls have been upgraded. If your contact image urls did not follow the standard format for image Urls they have not been upgraded. Please check the log to see image urls that were not upgraded.');
}
}
/**
* Upgrade 4.4.alpha1.
*
* @param string $rev
*
* @return bool
*/
public function upgrade_4_4_alpha1($rev) {
// task to process sql
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.alpha1')), 'runSql', $rev);
// Consolidate activity contacts CRM-12274.
$this->addTask('Consolidate activity contacts', 'activityContacts');
return TRUE;
}
/**
* @param $rev
*/
public function upgrade_4_4_beta1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.beta1')), 'runSql', $rev);
// add new 'data' column in civicrm_batch
$query = 'ALTER TABLE civicrm_batch ADD data LONGTEXT NULL COMMENT "cache entered data"';
CRM_Core_DAO::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE);
// check if batch entry data exists in civicrm_cache table
$query = 'SELECT path, data FROM civicrm_cache WHERE group_name = "batch entry"';
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
// get batch id $batchId[2]
$batchId = explode('-', $dao->path);
$data = unserialize($dao->data);
// move the data to civicrm_batch table
CRM_Core_DAO::setFieldValue('CRM_Batch_DAO_Batch', $batchId[2], 'data', json_encode(array('values' => $data)));
}
// delete entries from civicrm_cache table
$query = 'DELETE FROM civicrm_cache WHERE group_name = "batch entry"';
CRM_Core_DAO::executeQuery($query);
$this->addTask('Migrate custom word-replacements', 'wordReplacements');
}
/**
* @param $rev
*/
public function upgrade_4_4_1($rev) {
$config = CRM_Core_Config::singleton();
// CRM-13327 upgrade handling for the newly added name badges
$ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'name_badge', 'id', 'name');
$nameBadges = array_flip(array_values(CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('name_badge')));
unset($nameBadges['Avery 5395']);
if (!empty($nameBadges)) {
$dimension = '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}';
$query = "UPDATE civicrm_option_value
SET value = '{$dimension}'
WHERE option_group_id = %1 AND name = 'Fattorini Name Badge 100x65'";
CRM_Core_DAO::executeQuery($query, array(1 => array($ogID, 'Integer')));
}
else {
$dimensions = array(
1 => '{"paper-size":"a4","orientation":"landscape","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":1,"metric":"mm","lMargin":25,"tMargin":27,"SpaceX":0,"SpaceY":35,"width":106,"height":150,"lPadding":5,"tPadding":5}',
2 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":4,"metric":"mm","lMargin":6,"tMargin":19,"SpaceX":0,"SpaceY":0,"width":100,"height":65,"lPadding":0,"tPadding":0}',
3 => '{"paper-size":"a4","orientation":"portrait","font-name":"times","font-size":6,"font-style":"","NX":2,"NY":2,"metric":"mm","lMargin":10,"tMargin":28,"SpaceX":0,"SpaceY":0,"width":96,"height":121,"lPadding":5,"tPadding":5}',
);
$insertStatements = array(
1 => "($ogID, %1, '{$dimensions[1]}', %1, NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL)",
2 => "($ogID, %2, '{$dimensions[2]}', %2, NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL)",
3 => "($ogID, %3, '{$dimensions[3]}', %3, NULL, 0, NULL, 4, NULL, 0, 0, 1, NULL, NULL)",
);
$queryParams = array(
1 => array('A6 Badge Portrait 150x106', 'String'),
2 => array('Fattorini Name Badge 100x65', 'String'),
3 => array('Hanging Badge 3-3/4" x 4-3"/4', 'String'),
);
foreach ($insertStatements as $values) {
$query = 'INSERT INTO civicrm_option_value (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES' . $values;
CRM_Core_DAO::executeQuery($query, $queryParams);
}
}
// CRM-12578 - Prior to this version a CSS file under drupal would disable core css
if (!empty($config->customCSSURL) && strpos($config->userFramework, 'Drupal') === 0) {
// The new setting doesn't exist yet - need to create it first
$sql = '
INSERT INTO civicrm_setting (group_name, name , value , domain_id , is_domain , created_date)
VALUES (%1, %2, %3, %4, %5, now())';
CRM_Core_DAO::executeQuery($sql, array(
1 => array(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'String'),
2 => array('disable_core_css', 'String'),
3 => array(serialize(1), 'String'),
4 => array(CRM_Core_Config::domainID(), 'Positive'),
5 => array(1, 'Int'),
));
Civi::service('settings_manager')->flush();
}
// CRM-13701 - Fix $config->timeInputFormat
$sql = "
SELECT time_format
FROM civicrm_preferences_date
WHERE time_format IS NOT NULL
AND time_format <> ''
LIMIT 1
";
$timeInputFormat = CRM_Core_DAO::singleValueQuery($sql);
if ($timeInputFormat && $timeInputFormat != $config->timeInputFormat) {
$params = array('timeInputFormat' => $timeInputFormat);
CRM_Core_BAO_ConfigSetting::add($params);
}
// CRM-13698 - add 'Available' and 'No-show' activity statuses
$insertStatus = array();
$nsinc = $avinc = $inc = 0;
if (!CRM_Core_OptionGroup::getValue('activity_status', 'Available', 'name')) {
$insertStatus[] = "(%1, 'Available', %2, 'Available', NULL, 0, NULL, %3, 0, 0, 1, NULL, NULL)";
$avinc = $inc = 1;
}
if (!CRM_Core_OptionGroup::getValue('activity_status', 'No_show', 'name')) {
$insertStatus[] = "(%1, 'No-show', %4, 'No_show', NULL, 0, NULL, %5, 0, 0, 1, NULL, NULL)";
$nsinc = $inc + 1;
}
if (!empty($insertStatus)) {
$acOptionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_status', 'id', 'name');
$maxVal = CRM_Core_DAO::singleValueQuery("SELECT MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = $acOptionGroupID");
$maxWeight = CRM_Core_DAO::singleValueQuery("SELECT MAX(weight) FROM civicrm_option_value WHERE option_group_id = $acOptionGroupID");
$p[1] = array($acOptionGroupID, 'Integer');
if ($avinc) {
$p[2] = array($avinc + $maxVal, 'Integer');
$p[3] = array($avinc + $maxWeight, 'Integer');
}
if ($nsinc) {
$p[4] = array($nsinc + $maxVal, 'Integer');
$p[5] = array($nsinc + $maxWeight, 'Integer');
}
$insertStatus = implode(',', $insertStatus);
$sql = "
INSERT INTO
civicrm_option_value (`option_group_id`, label, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES {$insertStatus}";
CRM_Core_DAO::executeQuery($sql, $p);
}
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.1')), 'runSql', $rev);
$this->addTask('Patch word-replacement schema', 'wordReplacements_patch', $rev);
}
/**
* @param $rev
*
* @return bool
*/
public function upgrade_4_4_4($rev) {
$fkConstraint = array();
if (!CRM_Core_DAO::checkFKConstraintInFormat('civicrm_activity_contact', 'activity_id')) {
$fkConstraint[] = "ADD CONSTRAINT `FK_civicrm_activity_contact_activity_id` FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE CASCADE";
}
if (!CRM_Core_DAO::checkFKConstraintInFormat('civicrm_activity_contact', 'contact_id')) {
$fkConstraint[] = "ADD CONSTRAINT `FK_civicrm_activity_contact_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE;
";
}
if (!empty($fkConstraint)) {
$fkConstraint = implode(',', $fkConstraint);
$sql = "ALTER TABLE `civicrm_activity_contact`
{$fkConstraint}
";
// CRM-14036 : delete entries of un-mapped contacts
CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
LEFT JOIN civicrm_contact c
ON c.id = ac.contact_id
WHERE c.id IS NULL;
");
// delete entries of un-mapped activities
CRM_Core_DAO::executeQuery("DELETE ac FROM civicrm_activity_contact ac
LEFT JOIN civicrm_activity a
ON a.id = ac.activity_id
WHERE a.id IS NULL;
");
CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS=0;");
CRM_Core_DAO::executeQuery($sql);
CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS=1;");
}
// task to process sql
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.4.4')), 'runSql', $rev);
// CRM-13892 : add `name` column to dashboard schema
$query = "
ALTER TABLE civicrm_dashboard
ADD name varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Internal name of dashlet.' AFTER domain_id ";
CRM_Core_DAO::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE);
$dashboard = new CRM_Core_DAO_Dashboard();
$dashboard->find();
while ($dashboard->fetch()) {
$urlElements = explode('/', $dashboard->url);
if ($urlElements[1] == 'dashlet') {
$url = explode('&', $urlElements[2]);
$name = $url[0];
}
elseif ($urlElements[1] == 'report') {
$url = explode('&', $urlElements[3]);
$name = 'report/' . $url[0];
}
$values .= "
WHEN {$dashboard->id} THEN '{$name}'
";
}
$query = "
UPDATE civicrm_dashboard
SET name = CASE id
{$values}
END;
";
CRM_Core_DAO::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE);
// CRM-13998 : missing alter statements for civicrm_report_instance
$this->addTask(ts('Confirm civicrm_report_instance sql table for upgrades'), 'updateReportInstanceTable');
return TRUE;
}
/**
* @param $rev
*/
public function upgrade_4_4_6($rev) {
$sql = "SELECT count(*) AS count FROM INFORMATION_SCHEMA.STATISTICS where " .
"TABLE_SCHEMA = database() AND INDEX_NAME = 'index_image_url' AND TABLE_NAME = 'civicrm_contact';";
$dao = CRM_Core_DAO::executeQuery($sql);
$dao->fetch();
if ($dao->count < 1) {
$sql = "CREATE INDEX index_image_url ON civicrm_contact (image_url);";
$dao = CRM_Core_DAO::executeQuery($sql);
}
$minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL');
$maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL');
for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = "Upgrade image_urls ($startId => $endId)";
$this->addTask($title, 'upgradeImageUrls', $startId, $endId);
}
}
/**
* Upgrade script for 4.4.7.
*
* @param string $rev
* @param string $originalVer
* @param string $latestVer
*/
public function upgrade_4_4_7($rev, $originalVer, $latestVer) {
// For WordPress/Joomla(?), cleanup broken image_URL from 4.4.6 upgrades - https://issues.civicrm.org/jira/browse/CRM-14971
$exBackendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE); // URL formula from 4.4.6 upgrade
$exFrontendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE, NULL, TRUE, TRUE);
if ($originalVer == '4.4.6' && $exBackendUrl != $exFrontendUrl) {
$minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL');
$maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL');
for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = "Upgrade image_urls ($startId => $endId)";
$this->addTask($title, 'cleanupBackendImageUrls', $startId, $endId);
}
}
$this->addTask(ts('Update saved search information'), 'changeSavedSearch');
}
/**
* Upgrade image URLs.
*
* @param \CRM_Queue_TaskContext $ctx
* @param $startId
* @param $endId
*
* @return bool
*/
public static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$dao = self::findContactImageUrls($startId, $endId);
$failures = array();
$config = CRM_Core_Config::singleton();
while ($dao->fetch()) {
$imageURL = $dao->image_url;
$baseurl = CIVICRM_UF_BASEURL;
//CRM-15897 - gross hack for joomla to remove the administrator/
if ($config->userFramework == 'Joomla') {
$baseurl = str_replace("/administrator/", "/", $baseurl);
}
$baselen = strlen($baseurl);
if (substr($imageURL, 0, $baselen) == $baseurl) {
$photo = basename($dao->image_url);
$fullpath = $config->customFileUploadDir . $photo;
if (file_exists($fullpath)) {
// For anyone who upgraded 4.4.6 release (eg 4.4.0=>4.4.6), the $newImageUrl incorrectly used backend URLs.
// For anyone who skipped 4.4.6 (eg 4.4.0=>4.4.7), the $newImageUrl correctly uses frontend URLs
self::setContactImageUrl($dao->id,
CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=' . $photo, TRUE, NULL, TRUE, TRUE));
}
else {
$failures[$dao->id] = $dao->image_url;
}
}
else {
$failures[$dao->id] = $dao->image_url;
}
}
CRM_Core_Error::debug_var('imageUrlsNotUpgraded', $failures);
return TRUE;
}
/**
* Change saved search.
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function changeSavedSearch(CRM_Queue_TaskContext $ctx) {
$membershipStatuses = array_flip(CRM_Member_PseudoConstant::membershipStatus());
$dao = new CRM_Contact_DAO_SavedSearch();
$dao->find();
while ($dao->fetch()) {
$formValues = NULL;
if (!empty($dao->form_values)) {
$formValues = unserialize($dao->form_values);
}
if (!empty($formValues['mapper'])) {
foreach ($formValues['mapper'] as $key => $value) {
foreach ($value as $k => $v) {
if ($v[0] == 'Membership' && in_array($v[1], array('membership_status', 'membership_status_id'))) {
$value = $formValues['value'][$key][$k];
$op = $formValues['operator'][$key][$k];
if ($op == 'IN') {
$value = trim($value);
$value = str_replace('(', '', $value);
$value = str_replace(')', '', $value);
$v = explode(',', $value);
$value = array();
foreach ($v as $k1 => $v2) {
if (is_numeric($v2)) {
break 2;
}
$value[$k1] = $membershipStatuses[$v2];
}
$formValues['value'][$key][$k] = "(" . implode(',', $value) . ")";
}
elseif (in_array($op, array('=', '!='))) {
if (is_numeric($value)) {
break;
}
$formValues['value'][$key][$k] = $membershipStatuses[$value];
}
}
}
}
$dao->form_values = serialize($formValues);
$dao->save();
}
}
return TRUE;
}
/**
* For WordPress/Joomla(?) sites which upgraded to 4.4.6, find back-end image_URLs
* (e.g. "http://example.com/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/contact/imagefile&amp;photo=123.jpg")
* and convert them to front-end URLs
* (e.g. "http://example.com/?page=CiviCRM&amp;q=civicrm/contact/imagefile&amp;photo=123.jpg").
*
* @param CRM_Queue_TaskContext $ctx
* @param int $startId
* @param int $endId
* @return bool
*/
public static function cleanupBackendImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$dao = self::findContactImageUrls($startId, $endId);
while ($dao->fetch()) {
$imageUrl = str_replace('&amp;', '&', $dao->image_url);
if (preg_match(":civicrm/contact/imagefile.*photo=:", $imageUrl)) {
// looks like one of ours
$imageUrlParts = parse_url($imageUrl);
parse_str($imageUrlParts['query'], $imageUrlQuery);
self::setContactImageUrl($dao->id,
CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=' . $imageUrlQuery['photo'], TRUE, NULL, TRUE, TRUE));
}
}
return TRUE;
}
/**
* @param int $startId
* @param int $endId
* @return CRM_Core_DAO
* columns include "id" and "image_URL"
*/
public static function findContactImageUrls($startId, $endId) {
$sql = "
SELECT id, image_url
FROM civicrm_contact
WHERE 1
AND id BETWEEN %1 AND %2
AND image_URL IS NOT NULL
";
$params = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
$dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, NULL, FALSE, FALSE);
return $dao;
}
/**
* @param int $cid
* @param string $newImageUrl
*/
public static function setContactImageUrl($cid, $newImageUrl) {
$sql = 'UPDATE civicrm_contact SET image_url=%1 WHERE id=%2';
$params = array(
1 => array($newImageUrl, 'String'),
2 => array($cid, 'Integer'),
);
$updatedao = CRM_Core_DAO::executeQuery($sql, $params);
}
/**
* Update activity contacts CRM-12274
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool
* TRUE for success
*/
public static function activityContacts(CRM_Queue_TaskContext $ctx) {
$upgrade = new CRM_Upgrade_Form();
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$ovValue[] = $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$ovValue[] = $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$ovValue[] = $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_contacts', 'id', 'name');
if (!empty($ovValue)) {
$ovValues = implode(', ', $ovValue);
$query = "
UPDATE civicrm_option_value
SET is_reserved = 1
WHERE option_group_id = {$optionGroupID} AND value IN ($ovValues)";
$dao = CRM_Core_DAO::executeQuery($query);
}
if (!$assigneeID) {
$assigneeID = 1;
$value[] = "({$optionGroupID}, 'Activity Assignees', 1, 'Activity Assignees', 1, 1, 1)";
}
if (!$sourceID) {
$sourceID = 2;
$value[] = "({$optionGroupID}, 'Activity Source', 2, 'Activity Source', 2, 1, 1)";
}
if (!$targetID) {
$targetID = 3;
$value[] = "({$optionGroupID}, 'Activity Targets', 3, 'Activity Targets', 3, 1, 1)";
}
if (!$assigneeID || !$sourceID || !$targetID) {
$insert = "
INSERT INTO civicrm_option_value
(option_group_id, label, value, name, weight, is_reserved, is_active)
VALUES
";
$values = implode(', ', $value);
$query = $insert . $values;
$dao = CRM_Core_DAO::executeQuery($query);
}
// sometimes an user does not make a clean backup and the above table
// already exists, so lets delete this table - CRM-13665
$query = "DROP TABLE IF EXISTS civicrm_activity_contact";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "
CREATE TABLE IF NOT EXISTS civicrm_activity_contact (
id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Activity contact id',
activity_id int(10) unsigned NOT NULL COMMENT 'Foreign key to the activity for this record.',
contact_id int(10) unsigned NOT NULL COMMENT 'Foreign key to the contact for this record.',
record_type_id int(10) unsigned DEFAULT NULL COMMENT 'The record type id for this row',
PRIMARY KEY (id),
UNIQUE KEY UI_activity_contact (contact_id,activity_id,record_type_id),
KEY FK_civicrm_activity_contact_activity_id (activity_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "
INSERT INTO civicrm_activity_contact (activity_id, contact_id, record_type_id)
SELECT activity_id, target_contact_id, {$targetID} as record_type_id
FROM civicrm_activity_target";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "
INSERT INTO civicrm_activity_contact (activity_id, contact_id, record_type_id)
SELECT activity_id, assignee_contact_id, {$assigneeID} as record_type_id
FROM civicrm_activity_assignment";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "
INSERT INTO civicrm_activity_contact (activity_id, contact_id, record_type_id)
SELECT id, source_contact_id, {$sourceID} as record_type_id
FROM civicrm_activity
WHERE source_contact_id IS NOT NULL";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "DROP TABLE civicrm_activity_target";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "DROP TABLE civicrm_activity_assignment";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "ALTER TABLE civicrm_activity
DROP FOREIGN KEY FK_civicrm_activity_source_contact_id";
$dao = CRM_Core_DAO::executeQuery($query);
$query = "ALTER TABLE civicrm_activity DROP COLUMN source_contact_id";
$dao = CRM_Core_DAO::executeQuery($query);
return TRUE;
}
/**
* Migrate word-replacements from $config to civicrm_word_replacement
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool
* TRUE for success
* @see http://issues.civicrm.org/jira/browse/CRM-13187
*/
public static function wordReplacements(CRM_Queue_TaskContext $ctx) {
$query = "
CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Word replacement ID',
`find_word` varchar(255) COLLATE utf8_bin COMMENT 'Word which need to be replaced',
`replace_word` varchar(255) COLLATE utf8_bin COMMENT 'Word which will replace the word in find',
`is_active` tinyint COMMENT 'Is this entry active?',
`match_type` enum('wildcardMatch', 'exactMatch') DEFAULT 'wildcardMatch',
`domain_id` int unsigned COMMENT 'FK to Domain ID. This is for Domain specific word replacement',
PRIMARY KEY ( `id` ),
UNIQUE INDEX `UI_domain_find` (domain_id, find_word),
CONSTRAINT FK_civicrm_word_replacement_domain_id FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain`(`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
";
$dao = CRM_Core_DAO::executeQuery($query);
self::rebuildWordReplacementTable();
return TRUE;
}
/**
* Fix misconfigured constraints created in 4.4.0. To distinguish the good
* and bad configurations, we change the constraint name from "UI_find"
* (the original name in 4.4.0) to "UI_domain_find" (the new name in
* 4.4.1).
*
* @param CRM_Queue_TaskContext $ctx
* @param $rev
*
* @return bool
* TRUE for success
* @see http://issues.civicrm.org/jira/browse/CRM-13655
*/
public static function wordReplacements_patch(CRM_Queue_TaskContext $ctx, $rev) {
if (CRM_Core_DAO::checkConstraintExists('civicrm_word_replacement', 'UI_find')) {
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement DROP FOREIGN KEY FK_civicrm_word_replacement_domain_id;");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement DROP KEY FK_civicrm_word_replacement_domain_id;");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement DROP KEY UI_find;");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement MODIFY COLUMN `find_word` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT 'Word which need to be replaced';");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement MODIFY COLUMN `replace_word` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT 'Word which will replace the word in find';");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement ADD CONSTRAINT UI_domain_find UNIQUE KEY `UI_domain_find` (`domain_id`,`find_word`);");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_word_replacement ADD CONSTRAINT FK_civicrm_word_replacement_domain_id FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`);");
}
return TRUE;
}
/**
* Get all the word-replacements stored in config-arrays
* and convert them to params for the WordReplacement.create API.
*
* Note: This function is duplicated in CRM_Core_BAO_WordReplacement and
* CRM_Upgrade_Incremental_php_FourFour to ensure that the incremental upgrade
* step behaves consistently even as the BAO evolves in future versions.
* However, if there's a bug in here prior to 4.4.0, we should apply the
* bugfix in both places.
*
* @param bool $rebuildEach
* Whether to perform rebuild after each individual API call.
* @return array
* Each item is $params for WordReplacement.create
* @see CRM_Core_BAO_WordReplacement::convertConfigArraysToAPIParams
*/
public static function getConfigArraysAsAPIParams($rebuildEach) {
$wordReplacementCreateParams = array();
// get all domains
$result = civicrm_api3('domain', 'get', array(
'return' => array('locale_custom_strings'),
));
if (!empty($result["values"])) {
foreach ($result["values"] as $value) {
$params = array();
$params["domain_id"] = $value["id"];
$params["options"] = array('wp-rebuild' => $rebuildEach);
// unserialize word match string
$localeCustomArray = array();
if (!empty($value["locale_custom_strings"])) {
$localeCustomArray = unserialize($value["locale_custom_strings"]);
}
if (!empty($localeCustomArray)) {
$wordMatchArray = array();
// Traverse Language array
foreach ($localeCustomArray as $localCustomData) {
// Traverse status array "enabled" "disabled"
foreach ($localCustomData as $status => $matchTypes) {
$params["is_active"] = ($status == "enabled") ? TRUE : FALSE;
// Traverse Match Type array "wildcardMatch" "exactMatch"
foreach ($matchTypes as $matchType => $words) {
$params["match_type"] = $matchType;
foreach ($words as $word => $replace) {
$params["find_word"] = $word;
$params["replace_word"] = $replace;
$wordReplacementCreateParams[] = $params;
}
}
}
}
}
}
}
return $wordReplacementCreateParams;
}
/**
* Get all the word-replacements stored in config-arrays
* and write them out as records in civicrm_word_replacement.
*
* Note: This function is duplicated in CRM_Core_BAO_WordReplacement and
* CRM_Upgrade_Incremental_php_FourFour to ensure that the incremental upgrade
* step behaves consistently even as the BAO evolves in future versions.
* However, if there's a bug in here prior to 4.4.0, we should apply the
* bugfix in both places.
*/
public static function rebuildWordReplacementTable() {
civicrm_api3('word_replacement', 'replace', array(
'options' => array('match' => array('domain_id', 'find_word')),
'values' => array_filter(self::getConfigArraysAsAPIParams(FALSE), array(__CLASS__, 'isValidWordReplacement')),
));
CRM_Core_BAO_WordReplacement::rebuild();
}
/**
* CRM-13998 missing alter statements for civicrm_report_instance
*/
public function updateReportInstanceTable() {
// add civicrm_report_instance.name
$sql = "SELECT count(*) FROM information_schema.columns "
. "WHERE table_schema = database() AND table_name = 'civicrm_report_instance' AND COLUMN_NAME = 'name' ";
$res = CRM_Core_DAO::singleValueQuery($sql);
if ($res <= 0) {
$sql = "ALTER TABLE civicrm_report_instance ADD `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'when combined with report_id/template uniquely identifies the instance'";
$res = CRM_Core_DAO::executeQuery($sql);
}
// add civicrm_report_instance args
$sql = "SELECT count(*) FROM information_schema.columns WHERE table_schema = database() AND table_name = 'civicrm_report_instance' AND COLUMN_NAME = 'args' ";
$res = CRM_Core_DAO::singleValueQuery($sql);
if ($res <= 0) {
$sql = "ALTER TABLE civicrm_report_instance ADD `args` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'arguments that are passed in the url when invoking the instance'";
$res = CRM_Core_DAO::executeQuery($sql);
}
return TRUE;
}
/**
* @param array $params
* @return bool
* TRUE if $params is valid
*/
public static function isValidWordReplacement($params) {
$result = strlen($params['find_word']) <= self::MAX_WORD_REPLACEMENT_SIZE && strlen($params['replace_word']) <= self::MAX_WORD_REPLACEMENT_SIZE;
if (!$result) {
CRM_Core_Error::debug_var('invalidWordReplacement', $params);
}
return $result;
}
}

View file

@ -0,0 +1,430 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Upgrade_Incremental_php_FourOne {
// This was changed in 4.3 so we define it locally for compatibility with older dbs
const NAVIGATION_NAME = "Navigation Menu";
/**
* @param $errors
*
* @return bool
*/
public function verifyPreDBstate(&$errors) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviCase', $config->enableComponents)) {
if (!CRM_Core_DAO::checkTriggerViewPermission(TRUE, FALSE)) {
$errors[] = 'CiviCase now requires CREATE VIEW and DROP VIEW permissions for the database user.';
return FALSE;
}
}
return TRUE;
}
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '4.1.alpha1') {
$postUpgradeMessage .= '<br />' .
ts('WARNING! CiviCRM 4.1 introduces an improved way of handling cron jobs. However the new method is NOT backwards compatible. <strong>Please notify your system administrator that all CiviCRM related cron jobs will cease to work, and will need to be re-configured (this includes sending CiviMail mailings, updating membership statuses, etc.).</strong> Refer to the <a href="%1">online documentation</a> for detailed instructions.', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC41/Managing+Scheduled+Jobs'));
$postUpgradeMessage .= '<br />' .
ts('The CiviCRM Administration menu structure has been re-organized during this upgrade to make it easier to find things and reduce the number of keystrokes. If you have customized this portion of the navigation menu - you should take a few minutes to review the changes. You may need to reimplement or move your customizations.');
$postUpgradeMessage .= '<br />Yahoo recently discontinued their geocoding and mapping API service. If you previously used Yahoo, you will need to select and configure an alternate service in order to continue using geocoding/mapping tools.';
$postUpgradeMessage .= '<br />' .
ts('We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.');
}
}
/**
* @param $rev
*/
public function upgrade_4_1_alpha1($rev) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviCase', $config->enableComponents)) {
if (!CRM_Case_BAO_Case::createCaseViews()) {
$template = CRM_Core_Smarty::singleton();
$afterUpgradeMessage = '';
if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) {
$afterUpgradeMessage .= "<br/><br/>";
}
$afterUpgradeMessage .=
'<div class="crm-upgrade-case-views-error" style="background-color: #E43D2B; padding: 10px;">' .
ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:");
$afterUpgradeMessage .=
'<div class="crm-upgrade-case-views-query"><div>' .
CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '</div><div>' .
CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '</div>' .
'</div></div>';
$template->assign('afterUpgradeMessage', $afterUpgradeMessage);
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
$this->transferPreferencesToSettings();
$this->createNewSettings();
// now modify the config so that the directories are now stored in the settings table
// CRM-8780
$params = array();
CRM_Core_BAO_ConfigSetting::add($params);
// also reset navigation
CRM_Core_BAO_Navigation::resetNavigation();
}
public function transferPreferencesToSettings() {
// first transfer system preferences
$domainColumnNames = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
'contact_view_options',
'contact_edit_options',
'advanced_search_options',
'user_dashboard_options',
'address_options',
'address_format',
'mailing_format',
'display_name_format',
'sort_name_format',
'editor_id',
'contact_autocomplete_options',
),
CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => array(
'address_standardization_provider',
'address_standardization_userid',
'address_standardization_url',
),
CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
'mailing_backend',
),
);
$userColumnNames = array(
self::NAVIGATION_NAME => array(
'navigation',
),
);
$sql = "
SELECT *
FROM civicrm_preferences
WHERE domain_id = %1
";
$params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
$domainID = CRM_Core_Config::domainID();
$createdDate = date('YmdHis');
while ($dao->fetch()) {
if ($dao->is_domain) {
$values = array();
foreach ($domainColumnNames as $groupName => $settingNames) {
foreach ($settingNames as $settingName) {
if (empty($dao->$settingName)) {
$value = NULL;
}
else {
if ($settingName == 'mailing_backend') {
$value = $dao->$settingName;
}
else {
$value = serialize($dao->$settingName);
}
}
if ($value) {
$value = addslashes($value);
}
$value = $value ? "'{$value}'" : 'null';
$values[] = " ('{$groupName}','{$settingName}', {$value}, {$domainID}, null, 1, '{$createdDate}', null )";
}
}
}
else {
// this is a user setting
foreach ($userColumnNames as $groupName => $settingNames) {
foreach ($settingNames as $settingName) {
$value = empty($dao->$settingName) ? NULL : serialize($dao->$settingName);
if ($value) {
$value = addslashes($value);
}
$value = $value ? "'{$value}'" : 'null';
$values[] = " ('{$groupName}', '{$settingName}', {$value}, {$domainID}, {$dao->contact_id}, 0, '{$createdDate}', null )";
}
}
}
}
$sql = "
INSERT INTO civicrm_setting( group_name, name, value, domain_id, contact_id, is_domain, created_date, created_id )
VALUES
";
$sql .= implode(",\n", $values);
CRM_Core_DAO::executeQuery($sql);
// now drop the civicrm_preferences table
$sql = "DROP TABLE civicrm_preferences";
CRM_Core_DAO::executeQuery($sql);
}
public function createNewSettings() {
$domainColumns = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
array('contact_ajax_check_similar', 1),
array('activity_assignee_notification', 1),
),
CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array(
array('tag_unconfirmed', 'Unconfirmed'),
array('petition_contacts', 'Petition Contacts'),
),
CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array(
array('enable_cart', 0),
),
CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
array('profile_double_optin', 1),
array('profile_add_to_group_double_optin', 0),
array('track_civimail_replies', 0),
array('civimail_workflow', 0),
array('civimail_server_wide_lock', 0),
),
CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array(
array('default_renewal_contribution_page', NULL),
),
CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array(
array('is_enabled', 0),
array('uniq_email_per_site', 0),
array('domain_group_id', 0),
array('event_price_set_domain_id', 0),
),
CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => array(
array('uploadDir', NULL),
array('imageUploadDir', NULL),
array('customFileUploadDir', NULL),
array('customTemplateDir', NULL),
array('customPHPPathDir', NULL),
array('extensionsDir', NULL),
),
CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => array(
array('userFrameworkResourceURL', NULL),
array('imageUploadURL', NULL),
array('customCSSURL', NULL),
),
);
$domainID = CRM_Core_Config::domainID();
$createdDate = date('YmdHis');
$dbSettings = array();
self::retrieveDirectoryAndURLPaths($dbSettings);
foreach ($domainColumns as $groupName => $settings) {
foreach ($settings as $setting) {
if (isset($dbSettings[$groupName][$setting[0]]) &&
!empty($dbSettings[$groupName][$setting[0]])
) {
$setting[1] = $dbSettings[$groupName][$setting[0]];
}
$value = $setting[1] === NULL ? NULL : serialize($setting[1]);
if ($value) {
$value = addslashes($value);
}
$value = $value ? "'{$value}'" : 'null';
$values[] = "( '{$groupName}', '{$setting[0]}', {$value}, {$domainID}, null, 0, '{$createdDate}', null )";
}
}
$sql = "
INSERT INTO civicrm_setting( group_name, name, value, domain_id, contact_id, is_domain, created_date, created_id )
VALUES
";
$sql .= implode(",\n", $values);
CRM_Core_DAO::executeQuery($sql);
}
/**
* @param array $params
*/
public static function retrieveDirectoryAndURLPaths(&$params) {
$sql = "
SELECT v.name as valueName, v.value, g.name as optionName
FROM civicrm_option_value v,
civicrm_option_group g
WHERE ( g.name = 'directory_preferences'
OR g.name = 'url_preferences' )
AND v.option_group_id = g.id
AND v.is_active = 1
";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if (!$dao->value) {
continue;
}
$groupName = CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME;
if ($dao->optionName == 'url_preferences') {
$groupName = CRM_Core_BAO_Setting::URL_PREFERENCES_NAME;
}
$params[$groupName][$dao->valueName] = $dao->value;
}
}
/**
* @param $rev
*/
public function upgrade_4_1_alpha2($rev) {
$dao = new CRM_Core_DAO_Setting();
$dao->group_name = 'Directory Preferences';
$dao->name = 'customTemplateDir';
if (!($dao->find(TRUE))) {
$dao->domain_id = CRM_Core_Config::domainID();
$dao->created_date = date('YmdHis');
$dao->is_domain = 0;
$dao->save();
}
$dao->free();
// Do the regular upgrade
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
}
/**
* @param $rev
*/
public function upgrade_4_1_beta1($rev) {
//CRM-9311
$groupNames = array('directory_preferences', 'url_preferences');
foreach ($groupNames as $groupName) {
CRM_Core_OptionGroup::deleteAssoc($groupName);
}
$domainCols = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
'contact_ajax_check_similar',
'activity_assignee_notification',
),
CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array(
'tag_unconfirmed',
'petition_contacts',
),
CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array(
'enable_cart',
),
CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
'profile_double_optin',
'profile_add_to_group_double_optin',
'track_civimail_replies',
'civimail_workflow',
'civimail_server_wide_lock',
),
CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array(
'default_renewal_contribution_page',
),
CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array(
'is_enabled',
'uniq_email_per_site',
'domain_group_id',
'event_price_set_domain_id',
),
CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => array(
'uploadDir',
'imageUploadDir',
'customFileUploadDir',
'customTemplateDir',
'customPHPPathDir',
'extensionsDir',
),
CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => array(
'userFrameworkResourceURL',
'imageUploadURL',
'customCSSURL',
),
);
$arrGroupNames = array_keys($domainCols);
$groupNames = implode("','", $arrGroupNames);
$arrNames = array();
foreach ($domainCols as $groupName => $names) {
$arrNames[] = implode("','", $names);
}
$name = implode("','", $arrNames);
$sql = "
update civicrm_setting set is_domain = 1 where is_domain = 0 and group_name in ( '{$groupNames}' ) and name in ('{$name}')";
CRM_Core_DAO::executeQuery($sql);
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('addWightForActivity', !(CRM_Core_DAO::checkFieldExists('civicrm_activity', 'weight')));
$upgrade->processSQL($rev);
}
/**
* @param $rev
*/
public function upgrade_4_1_1($rev) {
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('addDedupeEmail', !(CRM_Core_DAO::checkFieldExists('civicrm_mailing', 'dedupe_email')));
$sql = "SELECT id FROM civicrm_worldregion LIMIT 1";
$upgrade->assign('worldRegionEmpty', !CRM_Core_DAO::singleValueQuery($sql));
$upgrade->processSQL($rev);
}
/**
* @return string
*/
public function getTemplateMessage() {
return "Blah";
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,201 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7.alpha1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Upgrade logic for 4.6
*/
class CRM_Upgrade_Incremental_php_FourSix extends CRM_Upgrade_Incremental_Base {
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '4.6.alpha1') {
$postUpgradeMessage .= '<br /><br />' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: <ul><li>Events - Registration Confirmation and Receipt (on-line)</li><li>Events - Registration Confirmation and Receipt (off-line)</li><li>Contributions - Receipt (on-line)</li><li>Contributions - Receipt (off-line)</li><li>Memberships - Receipt (on-line)</li><li>Memberships - Signup and Renewal Receipts (off-line)</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
}
if ($rev == '4.6.alpha3') {
$postUpgradeMessage .= '<br /><br />' . ts('A new permission has been added for editing message templates. Previously, users needed the "administer CiviCRM" permission. Now, users need the new permission called "edit message templates." Please check your CMS permissions to ensure that users who should be able to edit message templates are assigned this new permission.');
}
}
/**
* CRM-16846 - This function incorrectly omits running the 4.6.alpha3 sql file.
*
* Instead of correcting it here (which would not run again for sites already on 4.6),
* the file is re-run conditionally during 4.6.6
* @see upgrade_4_6_6
*
* @param string $rev
*/
public function upgrade_4_6_alpha3($rev) {
// Task to process sql.
$this->addTask('Add and update reference_date column for Schedule Reminders', 'updateReferenceDate');
}
/**
* Add new column reference_date to civicrm_action_log in order to track.
*
* CRM-15728, actual action_start_date for membership entity for only those schedule reminders which are not repeatable
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function updateReferenceDate(CRM_Queue_TaskContext $ctx) {
//Add column civicrm_action_log.reference_date if not exists.
$sql = "SELECT count(*) FROM information_schema.columns WHERE table_schema = database() AND table_name = 'civicrm_action_log' AND COLUMN_NAME = 'reference_date' ";
$res = CRM_Core_DAO::singleValueQuery($sql);
if ($res <= 0) {
$query = "ALTER TABLE `civicrm_action_log`
ADD COLUMN `reference_date` date COMMENT 'Stores the date from the entity which triggered this reminder action (e.g. membership.end_date for most membership renewal reminders)'";
CRM_Core_DAO::executeQuery($query);
}
//Retrieve schedule reminders for membership entity and is not repeatable and no absolute date chosen.
$query = "SELECT schedule.* FROM civicrm_action_schedule schedule
INNER JOIN civicrm_action_mapping mapper ON mapper.id = schedule.mapping_id AND
mapper.entity = 'civicrm_membership' AND
schedule.is_repeat = 0 AND
schedule.start_action_date IS NOT NULL";
// construct basic where clauses
$where = array(
'reminder.action_date_time >= DATE_SUB(reminder.action_date_time, INTERVAL 9 MONTH)',
); //choose reminder older then 9 months
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$referenceColumn = str_replace('membership_', "m.", $dao->start_action_date);
$value = implode(', ', explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($dao->entity_value, CRM_Core_DAO::VALUE_SEPARATOR)));
if (!empty($value)) {
$where[] = "m.membership_type_id IN ({$value})";
}
else {
$where[] = "m.membership_type_id IS NULL";
}
//Create new action_log records where action_start_date changes and exclude reminders for additional contacts
//and select contacts are active
$sql = "UPDATE civicrm_action_log reminder
LEFT JOIN civicrm_membership m
ON reminder.entity_id = m.id AND
reminder.entity_table = 'civicrm_membership' AND
( m.is_override IS NULL OR m.is_override = 0 )
INNER JOIN civicrm_contact c
ON c.id = m.contact_id AND
c.is_deleted = 0 AND c.is_deceased = 0
SET reminder.reference_date = {$referenceColumn}
WHERE " . implode(" AND ", $where);
CRM_Core_DAO::executeQuery($sql);
}
return TRUE;
}
/**
* Upgrade function.
*
* @param string $rev
*/
public function upgrade_4_6_1($rev) {
// CRM-16289 - Fix invalid data in log_civicrm_case.case_type_id.
$this->addTask('Cleanup case type id data in log table.', 'fixCaseLog');
}
/**
* Upgrade function.
*
* @param string $rev
*/
public function upgrade_4_6_6($rev) {
// CRM-16846 - This sql file may have been previously skipped. Conditionally run it again if it doesn't appear to have run before.
if (!CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_state_province WHERE abbreviation = '100' AND country_id = 1193")) {
$this->addTask('Update Slovenian municipalities', 'task_4_6_x_runOnlySql', '4.6.alpha3');
}
// CRM-16846 - This sql file may have been previously skipped. No harm in running it again because it's just UPDATE statements.
$this->addTask('State-province update from 4.4.7', 'task_4_6_x_runOnlySql', '4.4.7');
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
}
/**
* Remove special characters from case_type_id column in log_civicrm_case.
*
* CRM-16289 - If logging enabled and upgrading from 4.4 or earlier, log_civicrm_case.case_type_id will contain special characters.
* This will cause ALTER TABLE to fail when changing this column to an INT
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function fixCaseLog(CRM_Queue_TaskContext $ctx) {
$sql = "SELECT count(*) FROM information_schema.columns WHERE table_schema = database() AND table_name = 'log_civicrm_case'";
$res = CRM_Core_DAO::singleValueQuery($sql);
if ($res) {
// executeQuery doesn't like running multiple engine changes in one pass, so have to break it up. dgg
$query = "ALTER TABLE `log_civicrm_case` ENGINE = InnoDB;";
CRM_Core_DAO::executeQuery($query);
$query = "UPDATE log_civicrm_case SET case_type_id = replace(case_type_id, 0x01, '');";
CRM_Core_DAO::executeQuery($query);
$query = "ALTER TABLE `log_civicrm_case` ENGINE = ARCHIVE;";
CRM_Core_DAO::executeQuery($query);
$query = "ALTER TABLE log_civicrm_case MODIFY `case_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to civicrm_case_type.id';";
CRM_Core_DAO::executeQuery($query);
}
return TRUE;
}
/**
* Queue Task Callback for CRM-16846
*
* Run a sql file without resetting locale to that version
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $rev
*
* @return bool
*/
public static function task_4_6_x_runOnlySql(CRM_Queue_TaskContext $ctx, $rev) {
$upgrade = new CRM_Upgrade_Form();
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('domainID', CRM_Core_Config::domainID());
$fileName = dirname(__DIR__) . "/sql/$rev.mysql.tpl";
$upgrade->source($smarty->fetch($fileName), TRUE);
return TRUE;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,948 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Upgrade logic for 4.2
*/
class CRM_Upgrade_Incremental_php_FourTwo extends CRM_Upgrade_Incremental_Base {
const SETTINGS_SNIPPET_PATTERN = '/CRM_Core_ClassLoader::singleton\(\)-\>register/';
const SETTINGS_SNIPPET = "\nrequire_once 'CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
/**
* Compute any messages which should be displayed beforeupgrade.
*
* Note: This function is called iteratively for each upcoming
* revision to the database.
*
* @param string $preUpgradeMessage
* @param string $rev
* a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'.
* @param null $currentVer
*
* @return bool
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev == '4.2.alpha1') {
$tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
$errors = "The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to " . CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki");
CRM_Core_Error::fatal($errors);
return FALSE;
}
// CRM-10613, CRM-11120
$query = "
SELECT mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id
FROM civicrm_membership_payment mp
INNER JOIN ( SELECT cmp.contribution_id
FROM civicrm_membership_payment cmp
LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
WHERE cli.entity_id IS NULL
GROUP BY cmp.contribution_id
HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
ORDER BY mp.contribution_id, mp.membership_id";
$invalidData = CRM_Core_DAO::executeQuery($query);
if ($invalidData->N) {
$invalidDataMessage = "<br /><strong>" . 'The upgrade is being aborted due to data integrity issues in your database. There are multiple membership records linked to the same contribution record. This is unexpected, and some of the membership records may be duplicates. The problem record sets are listed below. Refer to <a href="http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades">this wiki page for instructions on repairing your database</a> so that you can run the upgrade successfully.' . "</strong>";
$membershipType = CRM_Member_PseudoConstant::membershipType();
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
$invalidDataMessage .= "<table border=1><tr><th>Contact-ID</th><th>Contribution-ID</th><th>Membership-ID</th><th>Membership Type</th><th>Start Date</th><th>End Date</th><th>Membership Status</th></tr>";
while ($invalidData->fetch()) {
$invalidDataMessage .= "<tr>";
$invalidDataMessage .= "<td>{$invalidData->contact_id}</td>";
$invalidDataMessage .= "<td>{$invalidData->contribution_id}</td>";
$invalidDataMessage .= "<td>{$invalidData->membership_id}</td>";
$invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->membership_type_id, $membershipType) . "</td>";
$invalidDataMessage .= "<td>{$invalidData->start_date}</td>";
$invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
$invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
$invalidDataMessage .= "</tr>";
}
$clickHere = CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1');
$invalidDataMessage .= "</table><p>If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href='$clickHere'>click here</a>.</p>";
CRM_Core_Error::fatal($invalidDataMessage);
return FALSE;
}
}
if ($rev == '4.2.beta2') {
// note: error conditions are also checked in upgrade_4_2_beta2()
if (!defined('CIVICRM_SETTINGS_PATH')) {
$preUpgradeMessage .= '<br />' . ts('Could not determine path to civicrm.settings.php. Please manually locate it and add these lines at the bottom: <pre>%1</pre>', array(
1 => self::SETTINGS_SNIPPET,
));
}
elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
// OK, nothing to do
}
elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
$preUpgradeMessage .= '<br />' . ts('The settings file (%1) must be updated. Please make it writable or manually add these lines:<pre>%2</pre>', array(
1 => CIVICRM_SETTINGS_PATH,
2 => self::SETTINGS_SNIPPET,
));
}
}
if ($rev == '4.2.2' && version_compare($currentVer, '3.3.alpha1') >= 0) {
$query = " SELECT cli.id
FROM `civicrm_line_item` cli
INNER JOIN civicrm_membership_payment cmp ON cmp.contribution_id = cli.entity_id AND cli.entity_table = 'civicrm_contribution'
INNER JOIN civicrm_price_field_value cpfv ON cpfv.id = cli.price_field_value_id
INNER JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id and cpf.id != cli.price_field_id
INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'default_membership_type_amount' ";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
$preUpgradeMessage .= "<br /><strong>We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href='http://forum.civicrm.org/index.php/topic,26181.0.html'>http://forum.civicrm.org/index.php/topic,26181.0.html</a>.</strong>";
}
}
if (version_compare($rev, '4.2.9') >= 0) {
//CRM-11980
$sql = "SELECT id FROM civicrm_option_group WHERE name LIKE 'civicrm_price_field.amount.%' LIMIT 1";
$dao = CRM_Core_DAO::executeQuery($sql);
if ($dao->fetch()) {
$errors = "We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'>Check here for information on diagnosing and correcting this problem.</a>";
CRM_Core_Error::fatal($errors);
return FALSE;
}
}
}
/**
* Compute any messages which should be displayed after upgrade.
*
* @param string $postUpgradeMessage
* alterable.
* @param string $rev
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '4.2.beta5') {
$config = CRM_Core_Config::singleton();
if (!empty($config->extensionsDir)) {
$postUpgradeMessage .= '<br />' . ts('Please <a href="%1" target="_blank">configure the Extension Resource URL</a>.', array(
1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'),
));
}
}
if ($rev == '4.2.7') {
$postUpgradeMessage .= '<br />' . ts('If you have configured a report instance to allow anonymous access, you will need to reset the permission to Everyone for that instance (under the Report Settings pane).');
}
}
/**
* @param $rev
*/
public function upgrade_4_2_alpha1($rev) {
//checking whether the foreign key exists before dropping it
//drop foreign key queries of CRM-9850
$params = array();
$tables = array(
'civicrm_contribution_page' => 'FK_civicrm_contribution_page_payment_processor_id',
'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
'civicrm_group' => 'FK_civicrm_group_saved_search_id',
);
foreach ($tables as $tableName => $fKey) {
$foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
if ($foreignKeyExists) {
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
}
}
// Drop index UI_title for civicrm_price_set
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
foreach ($locales as $locale) {
$query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title_{$locale}'";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
if ($dao->N) {
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
}
}
}
else {
$query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title'";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title`");
}
}
// Some steps take a long time, so we break them up into separate
// tasks and enqueue them separately.
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.alpha1')), 'runSql', $rev);
$this->addTask('Upgrade DB to 4.2.alpha1: Price Sets', 'task_4_2_alpha1_createPriceSets', $rev);
self::convertContribution();
$this->addTask('Upgrade DB to 4.2.alpha1: Event Profile', 'task_4_2_alpha1_eventProfile');
}
/**
* @param $rev
*/
public function upgrade_4_2_beta2($rev) {
// note: error conditions are also checked in setPreUpgradeMessage()
if (defined('CIVICRM_SETTINGS_PATH')) {
if (!preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
if (is_writable(CIVICRM_SETTINGS_PATH)) {
file_put_contents(CIVICRM_SETTINGS_PATH, self::SETTINGS_SNIPPET, FILE_APPEND);
}
}
}
}
/**
* @param $rev
*/
public function upgrade_4_2_beta3($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.beta3')), 'runSql', $rev);
$minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
$maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
$this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
}
}
/**
* @param $rev
*/
public function upgrade_4_2_beta5($rev) {
// CRM-10629 Create a setting for extension URLs
// For some reason, this isn't working when placed in the .sql file
CRM_Core_DAO::executeQuery("
INSERT INTO civicrm_setting(group_name,name,value,domain_id,is_domain)
VALUES ('URL Preferences', 'extensionsURL',NULL,1,1);
");
}
/**
* @param $rev
*/
public function upgrade_4_2_0($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.0')), 'runSql', $rev);
}
/**
* @param $rev
*/
public function upgrade_4_2_2($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.2')), 'runSql', $rev);
//create line items for memberships and participants for api/import
self::convertContribution();
// CRM-10937 Fix the title on civicrm_dedupe_rule_group
$upgrade = new CRM_Upgrade_Form();
if ($upgrade->multilingual) {
// Check if the 'title' field exists
$query = "SELECT column_name
FROM information_schema.COLUMNS
WHERE table_name = 'civicrm_dedupe_rule_group'
AND table_schema = DATABASE()
AND column_name = 'title'";
$dao = CRM_Core_DAO::executeQuery($query);
if (!$dao->N) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
$locale = array_shift($locales);
// Use the first language (they should all have the same value)
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` CHANGE `title_{$locale}` `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Label of the rule group'", $params, TRUE, NULL, FALSE, FALSE);
// Drop remaining the column for the remaining languages
foreach ($locales as $locale) {
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` DROP `title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
}
}
}
}
}
/**
* @param $rev
*/
public function upgrade_4_2_3($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.3')), 'runSql', $rev);
// CRM-10953 Remove duplicate activity type for 'Reminder Sent' which is mistakenly inserted by 4.2.alpha1 upgrade script
$queryMin = "
SELECT coalesce(min(value),0) from civicrm_option_value ov
WHERE ov.option_group_id =
(SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
ov.name = 'Reminder Sent'";
$minReminderSent = CRM_Core_DAO::singleValueQuery($queryMin);
$queryMax = "
SELECT coalesce(max(value),0) from civicrm_option_value ov
WHERE ov.option_group_id =
(SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
ov.name = 'Reminder Sent'";
$maxReminderSent = CRM_Core_DAO::singleValueQuery($queryMax);
// If we have two different values, replace new value with original in any activities
if ($maxReminderSent > $minReminderSent) {
$query = "
UPDATE civicrm_activity
SET activity_type_id = {$minReminderSent}
WHERE activity_type_id = {$maxReminderSent}";
CRM_Core_DAO::executeQuery($query);
// Then delete the newer (duplicate) option_value row
$query = "
DELETE from civicrm_option_value
WHERE option_group_id =
(SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
value = '{$maxReminderSent}'";
CRM_Core_DAO::executeQuery($query);
}
}
/**
* @param $rev
*/
public function upgrade_4_2_5($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.5')), 'runSql', $rev);
//CRM-11077
$sql = " SELECT cpse.entity_id, cpse.price_set_id
FROM `civicrm_price_set_entity` cpse
LEFT JOIN civicrm_price_set cps ON cps.id = cpse.price_set_id
LEFT JOIN civicrm_price_set_entity cpse1 ON cpse1.price_set_id = cpse.price_set_id
WHERE cpse.entity_table = 'civicrm_event' AND cps.is_quick_config = 1
GROUP BY cpse.id
HAVING COUNT(cpse.price_set_id) > 1 AND MIN(cpse1.id) <> cpse.id ";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if ($dao->price_set_id) {
$copyPriceSet = &CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::copy($dao->price_set_id);
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo('civicrm_event', $dao->entity_id, $copyPriceSet->id);
}
}
}
public function convertContribution() {
$minContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
$maxContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
for ($startId = $minContributionId; $startId <= $maxContributionId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = "Upgrade DB to 4.2.alpha1: Contributions ($startId => $endId)";
$this->addTask($title, 'task_4_2_alpha1_convertContributions', $startId, $endId);
}
$minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
$maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
$this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
}
}
/**
* (Queue Task Callback)
*
* Upgrade code to create priceset for contribution pages and events
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $rev
*
* @return bool
*/
public static function task_4_2_alpha1_createPriceSets(CRM_Queue_TaskContext $ctx, $rev) {
$upgrade = new CRM_Upgrade_Form();
$daoName = array(
'civicrm_contribution_page' => array(
'CRM_Contribute_BAO_ContributionPage',
CRM_Core_Component::getComponentID('CiviContribute'),
),
'civicrm_event' => array(
'CRM_Event_BAO_Event',
CRM_Core_Component::getComponentID('CiviEvent'),
),
);
// get all option group used for event and contribution page
$query = "
SELECT id, name
FROM civicrm_option_group
WHERE name LIKE '%.amount.%' ";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$addTo = explode('.', $dao->name);
if (!empty($addTo[2])) {
$options = array('optionGroup' => $dao->name);
self::createPriceSet($daoName, $addTo, $options);
}
CRM_Core_OptionGroup::deleteAssoc($dao->name);
}
//create pricesets for contribution with only other amount
$query = "
SELECT ccp.id as contribution_page_id, ccp.is_allow_other_amount, cmb.id as membership_block_id
FROM civicrm_contribution_page ccp
LEFT JOIN civicrm_membership_block cmb ON cmb.entity_id = ccp.id AND cmb.entity_table = 'civicrm_contribution_page'
LEFT JOIN civicrm_price_set_entity cpse ON cpse.entity_id = ccp.id and cpse.entity_table = 'civicrm_contribution_page'
WHERE cpse.price_set_id IS NULL";
$dao = CRM_Core_DAO::executeQuery($query);
$addTo = array('civicrm_contribution_page');
while ($dao->fetch()) {
$addTo[2] = $dao->contribution_page_id;
$options = array(
'otherAmount' => $dao->is_allow_other_amount,
'membership' => $dao->membership_block_id,
);
self::createPriceSet($daoName, $addTo, $options);
}
return TRUE;
}
/**
* Create price sets.
*
* @param string $daoName
* @param string $addTo
* @param array $options
*/
public static function createPriceSet($daoName, $addTo, $options = array()) {
$query = "SELECT title FROM {$addTo[0]} where id =%1";
$setParams['title'] = CRM_Core_DAO::singleValueQuery($query,
array(1 => array($addTo[2], 'Integer'))
);
$pageTitle = strtolower(CRM_Utils_String::munge($setParams['title'], '_', 245));
// an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
// we should probably delete the option group - but at least early exit here as the code following it does not fatal
// CRM-10298
if (empty($pageTitle)) {
return;
}
$optionValue = array();
if (!empty($options['optionGroup'])) {
CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
if (empty($optionValue)) {
return;
}
}
elseif (empty($options['otherAmount']) && empty($options['membership'])) {
//CRM-12273
//if options group, otherAmount, membersip is empty then return, contribution should be default price set
return;
}
if (!CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
$setParams['name'] = $pageTitle;
}
else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['extends'] = $daoName[$addTo[0]][1];
$setParams['is_quick_config'] = 1;
$priceSet = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo($addTo[0], $addTo[2], $priceSet->id, 1);
$fieldParams['price_set_id'] = $priceSet->id;
if (!empty($options['optionGroup'])) {
$fieldParams['html_type'] = 'Radio';
$fieldParams['is_required'] = 1;
if ($addTo[0] == 'civicrm_event') {
$query = "SELECT fee_label FROM civicrm_event where id =%1";
$fieldParams['name'] = $fieldParams['label'] = CRM_Core_DAO::singleValueQuery($query,
array(1 => array($addTo[2], 'Integer'))
);
$defaultAmountColumn = 'default_fee_id';
}
else {
$options['membership'] = 1;
$fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
$fieldParams['label'] = "Contribution Amount";
$defaultAmountColumn = 'default_amount_id';
$options['otherAmount'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $addTo[2], 'is_allow_other_amount');
if (!empty($options['otherAmount'])) {
$fieldParams['is_required'] = 0;
}
}
$fieldParams['option_label'] = $optionValue['label'];
$fieldParams['option_amount'] = $optionValue['value'];
$fieldParams['option_weight'] = $optionValue['weight'];
$fieldParams['is_quick_config'] = $setParams['is_quick_config'];
if ($defaultAmount = CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], $defaultAmountColumn)) {
$fieldParams['default_option'] = array_search($defaultAmount, $optionValue['amount_id']);
}
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
}
if (!empty($options['membership'])) {
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $addTo[2];
if ($dao->find(TRUE)) {
if ($dao->membership_types) {
$fieldParams = array(
'name' => strtolower(CRM_Utils_String::munge("Membership Amount", '_', 245)),
'label' => "Membership Amount",
'is_required' => $dao->is_required,
'is_display_amounts' => $dao->display_min_fee,
'is_active' => $dao->is_active,
'price_set_id' => $priceSet->id,
'html_type' => 'Radio',
'weight' => 1,
);
$membershipTypes = unserialize($dao->membership_types);
$rowcount = 0;
foreach ($membershipTypes as $membershipType => $autoRenew) {
$membershipTypeDetail = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipType);
$rowcount++;
$fieldParams['option_label'][$rowcount] = $membershipTypeDetail['name'];
$fieldParams['option_amount'][$rowcount] = $membershipTypeDetail['minimum_fee'];
$fieldParams['option_weight'][$rowcount] = $rowcount;
$fieldParams['membership_type_id'][$rowcount] = $membershipType;
if ($membershipType == $dao->membership_type_default) {
$fieldParams['default_option'] = $rowcount;
}
}
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
$setParams = array(
'id' => $priceSet->id,
'extends' => CRM_Core_Component::getComponentID('CiviMember'),
'contribution_type_id' => CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], 'contribution_type_id'),
);
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
}
}
}
if (!empty($options['otherAmount'])) {
$fieldParams = array(
'name' => strtolower(CRM_Utils_String::munge("Other Amount", '_', 245)),
'label' => "Other Amount",
'is_required' => 0,
'is_display_amounts' => 0,
'is_active' => 1,
'price_set_id' => $priceSet->id,
'html_type' => 'Text',
'weight' => 3,
);
$fieldParams['option_label'][1] = "Other Amount";
$fieldParams['option_amount'][1] = 1;
$fieldParams['option_weight'][1] = 1;
$priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
}
}
/**
* (Queue Task Callback)
*
* Find any contribution records and create corresponding line-item
* records.
*
* @param CRM_Queue_TaskContext $ctx
* @param int $startId
* the first/lowest contribution ID to convert.
* @param int $endId
* the last/highest contribution ID to convert.
*
* @return bool
*/
public static function task_4_2_alpha1_convertContributions(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$upgrade = new CRM_Upgrade_Form();
$query = "
INSERT INTO civicrm_line_item(`entity_table` ,`entity_id` ,`price_field_id` ,`label` , `qty` ,`unit_price` ,`line_total` ,`participant_count` ,`price_field_value_id`)
SELECT 'civicrm_contribution',cc.id, cpf.id as price_field_id, cpfv.label, 1, cc.total_amount, cc.total_amount line_total, 0, cpfv.id as price_field_value
FROM civicrm_membership_payment cmp
LEFT JOIN `civicrm_contribution` cc ON cc.id = cmp.contribution_id
LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_membership cm ON cm.id=cmp.membership_id
LEFT JOIN civicrm_membership_type cmt ON cmt.id = cm.membership_type_id
LEFT JOIN civicrm_price_field cpf ON BINARY cpf.name = cmt.member_of_contact_id
LEFT JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cm.membership_type_id AND cpf.id = cpfv.price_field_id
WHERE (cc.id BETWEEN %1 AND %2) AND cli.entity_id IS NULL ;
";
$sqlParams = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
CRM_Core_DAO::executeQuery($query, $sqlParams);
// create lineitems for contribution done for membership
$sql = "
SELECT cc.id, cmp.membership_id, cpse.price_set_id, cc.total_amount
FROM civicrm_contribution cc
LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id AND cli.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
LEFT JOIN civicrm_price_set_entity cpse on cpse.entity_table = 'civicrm_contribution_page' AND cpse.entity_id = cc.contribution_page_id
WHERE (cc.id BETWEEN %1 AND %2)
AND cli.entity_id IS NULL AND cc.contribution_page_id IS NOT NULL AND cpp.contribution_id IS NULL
GROUP BY cc.id, cmp.membership_id
";
$result = CRM_Core_DAO::executeQuery($sql, $sqlParams);
while ($result->fetch()) {
$sql = "
SELECT cpf.id, cpfv.id as price_field_value_id, cpfv.label, cpfv.amount, cpfv.count
FROM civicrm_price_field cpf
LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
WHERE cpf.price_set_id = %1
";
$lineParams = array(
'entity_table' => 'civicrm_contribution',
'entity_id' => $result->id,
);
if ($result->membership_id) {
$sql .= " AND cpf.name = %2 AND cpfv.membership_type_id = %3 ";
$params = array(
'1' => array($result->price_set_id, 'Integer'),
'2' => array('membership_amount', 'String'),
'3' => array(
CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $result->membership_id, 'membership_type_id'),
'Integer',
),
);
$res = CRM_Core_DAO::executeQuery($sql, $params);
if ($res->fetch()) {
$lineParams += array(
'price_field_id' => $res->id,
'label' => $res->label,
'qty' => 1,
'unit_price' => $res->amount,
'line_total' => $res->amount,
'participant_count' => $res->count ? $res->count : 0,
'price_field_value_id' => $res->price_field_value_id,
);
}
else {
$lineParams['price_field_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
$lineParams['label'] = 'Membership Amount';
$lineParams['qty'] = 1;
$lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
$lineParams['participant_count'] = 0;
}
}
else {
$sql .= "AND cpfv.amount = %2";
//CRM-12273
//check if price_set_id is exist, if not use the default contribution amount
if (isset($result->price_set_id)) {
$priceSetId = $result->price_set_id;
}
else {
$defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
foreach ($defaultPriceSets as $key => $pSet) {
if ($pSet['name'] == 'contribution_amount') {
$priceSetId = $pSet['setID'];
}
}
}
$params = array(
'1' => array($priceSetId, 'Integer'),
'2' => array($result->total_amount, 'String'),
);
$res = CRM_Core_DAO::executeQuery($sql, $params);
if ($res->fetch()) {
$lineParams += array(
'price_field_id' => $res->id,
'label' => $res->label,
'qty' => 1,
'unit_price' => $res->amount,
'line_total' => $res->amount,
'participant_count' => $res->count ? $res->count : 0,
'price_field_value_id' => $res->price_field_value_id,
);
}
else {
$params = array(
'price_set_id' => $priceSetId,
'name' => 'other_amount',
);
$defaults = array();
CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::retrieve($params, $defaults);
if (!empty($defaults)) {
$lineParams['price_field_id'] = $defaults['id'];
$lineParams['label'] = $defaults['label'];
$lineParams['price_field_value_id']
= CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $defaults['id'], 'id', 'price_field_id');
}
else {
$lineParams['price_field_id']
= CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
$lineParams['label'] = 'Contribution Amount';
}
$lineParams['qty'] = 1;
$lineParams['participant_count'] = 0;
$lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
}
}
CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
}
return TRUE;
}
/**
* (Queue Task Callback)
*
* Find any participant records and create corresponding line-item
* records.
*
* @param CRM_Queue_TaskContext $ctx
* @param int $startId
* the first/lowest participant ID to convert.
* @param int $endId
* the last/highest participant ID to convert.
*
* @return bool
*/
public static function task_4_2_alpha1_convertParticipants(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$upgrade = new CRM_Upgrade_Form();
//create lineitems for participant in edge cases using default price set for contribution.
$query = "
SELECT cp.id as participant_id, cp.fee_amount, cp.fee_level,ce.is_monetary,
cpse.price_set_id, cpf.id as price_field_id, cpfv.id as price_field_value_id
FROM civicrm_participant cp
LEFT JOIN civicrm_line_item cli ON cli.entity_id=cp.id and cli.entity_table = 'civicrm_participant'
LEFT JOIN civicrm_event ce ON ce.id=cp.event_id
LEFT JOIN civicrm_price_set_entity cpse ON cp.event_id = cpse.entity_id and cpse.entity_table = 'civicrm_event'
LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpse.price_set_id
LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id AND cpfv.label = cp.fee_level
WHERE (cp.id BETWEEN %1 AND %2)
AND cli.entity_id IS NULL AND cp.fee_amount IS NOT NULL";
$sqlParams = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
$dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
if ($dao->N) {
$defaultPriceSetId = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
$priceSets = current(CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::getSetDetail($defaultPriceSetId));
$fieldID = key($priceSets['fields']);
}
while ($dao->fetch()) {
$lineParams = array(
'entity_table' => 'civicrm_participant',
'entity_id' => $dao->participant_id,
'label' => $dao->fee_level ? $dao->fee_level : ts('Default'),
'qty' => 1,
'unit_price' => $dao->fee_amount,
'line_total' => $dao->fee_amount,
'participant_count' => 1,
);
if ($dao->is_monetary && $dao->price_field_id) {
$lineParams += array(
'price_field_id' => $dao->price_field_id,
'price_field_value_id' => $dao->price_field_value_id,
);
$priceSetId = $dao->price_set_id;
}
else {
$lineParams['price_field_id'] = $fieldID;
$priceSetId = $defaultPriceSetId;
}
CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
}
return TRUE;
}
/**
* (Queue Task Callback)
*
* Create an event registration profile with a single email field CRM-9587
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function task_4_2_alpha1_eventProfile(CRM_Queue_TaskContext $ctx) {
$upgrade = new CRM_Upgrade_Form();
$profileTitle = ts('Your Registration Info');
$sql = "
INSERT INTO civicrm_uf_group
(is_active, group_type, title, help_pre, help_post, limit_listings_group_id, post_URL, add_to_group_id, add_captcha, is_map, is_edit_link, is_uf_link, is_update_dupe, cancel_URL, is_cms_user, notify, is_reserved, name, created_id, created_date, is_proximity_search)
VALUES
(1, 'Individual, Contact', %1, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0, 'event_registration', NULL, NULL, 0);
";
$params = array(
1 => array($profileTitle, 'String'),
);
CRM_Core_DAO::executeQuery($sql, $params);
$eventRegistrationId = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
$sql = "
INSERT INTO civicrm_uf_field
(uf_group_id, field_name, is_active, is_view, is_required, weight, help_post, help_pre, visibility, in_selector, is_searchable, location_type_id, phone_type_id, label, field_type, is_reserved)
VALUES
({$eventRegistrationId}, 'email', 1, 0, 1, 1, NULL, NULL, 'User and User Admin Only', 0, 0, NULL, NULL, 'Email Address', 'Contact', 0);
";
CRM_Core_DAO::executeQuery($sql);
$sql = "SELECT * FROM civicrm_event WHERE is_online_registration = 1;";
$events = CRM_Core_DAO::executeQuery($sql);
while ($events->fetch()) {
// Get next weights for the event registration profile
$nextMainWeight = $nextAdditionalWeight = 1;
$sql = "
SELECT weight
FROM civicrm_uf_join
WHERE entity_id = {$events->id} AND module = 'CiviEvent'
ORDER BY weight DESC LIMIT 1";
$weights = CRM_Core_DAO::executeQuery($sql);
$weights->fetch();
if (isset($weights->weight)) {
$nextMainWeight += $weights->weight;
}
$sql = "
SELECT weight
FROM civicrm_uf_join
WHERE entity_id = {$events->id} AND module = 'CiviEvent_Additional'
ORDER BY weight DESC LIMIT 1";
$weights = CRM_Core_DAO::executeQuery($sql);
$weights->fetch();
if (isset($weights->weight)) {
$nextAdditionalWeight += $weights->weight;
}
// Add an event registration profile to the event
$sql = "
INSERT INTO civicrm_uf_join
(is_active, module, entity_table, entity_id, weight, uf_group_id)
VALUES
(1, 'CiviEvent', 'civicrm_event', {$events->id}, {$nextMainWeight}, {$eventRegistrationId});
";
CRM_Core_DAO::executeQuery($sql);
$sql = "
INSERT INTO civicrm_uf_join
(is_active, module, entity_table, entity_id, weight, uf_group_id)
VALUES
(1, 'CiviEvent_Additional', 'civicrm_event', {$events->id}, {$nextAdditionalWeight}, {$eventRegistrationId});";
CRM_Core_DAO::executeQuery($sql);
}
return TRUE;
}
/**
* @return array
*/
public static function deleteInvalidPairs() {
require_once 'CRM/Member/PseudoConstant.php';
require_once 'CRM/Contribute/PseudoConstant.php';
$processedRecords = array();
$tempTableName1 = CRM_Core_DAO::createTempTableName();
// 1. collect all duplicates
$sql = "
CREATE TEMPORARY TABLE {$tempTableName1} SELECT mp.id as payment_id, mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id, con.contribution_status_id
FROM civicrm_membership_payment mp
INNER JOIN ( SELECT cmp.contribution_id
FROM civicrm_membership_payment cmp
LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
WHERE cli.entity_id IS NULL
GROUP BY cmp.contribution_id
HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
INNER JOIN civicrm_contribution con ON con.id = mp.contribution_id
ORDER BY mp.contribution_id, mp.membership_id";
$dao = CRM_Core_DAO::executeQuery($sql);
$tempTableName2 = CRM_Core_DAO::createTempTableName();
// 2. collect all records that are going to be retained
$sql = "
CREATE TEMPORARY TABLE {$tempTableName2}
SELECT MAX(payment_id) as payment_id FROM {$tempTableName1} GROUP BY contribution_id HAVING COUNT(*) > 1";
CRM_Core_DAO::executeQuery($sql);
// 3. do the un-linking
$sql = "
DELETE cmp.*
FROM civicrm_membership_payment cmp
INNER JOIN $tempTableName1 temp1 ON temp1.payment_id = cmp.id
LEFT JOIN $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id
WHERE temp2.payment_id IS NULL";
CRM_Core_DAO::executeQuery($sql);
// 4. show all records that were Processed, i.e Retained vs Un-linked
$sql = "
SELECT temp1.contact_id, temp1.contribution_id, temp1.contribution_status_id, temp1.membership_id, temp1.membership_type_id, temp1.start_date, temp1.end_date, temp1.status_id, temp2.payment_id as retain_id
FROM $tempTableName1 temp1
LEFT JOIN $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id";
$dao = CRM_Core_DAO::executeQuery($sql);
if ($dao->N) {
$membershipType = CRM_Member_PseudoConstant::membershipType();
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
while ($dao->fetch()) {
$status = $dao->retain_id ? 'Retained' : 'Un-linked';
$memType = CRM_Utils_Array::value($dao->membership_type_id, $membershipType);
$memStatus = CRM_Utils_Array::value($dao->status_id, $membershipStatus);
$contribStatus = CRM_Utils_Array::value($dao->contribution_status_id, $contributionStatus);
$processedRecords[] = array(
$dao->contact_id,
$dao->contribution_id,
$contribStatus,
$dao->membership_id,
$memType,
$dao->start_date,
$dao->end_date,
$memStatus,
$status,
);
}
}
if (!empty($processedRecords)) {
CRM_Core_Error::debug_log_message("deleteInvalidPairs() - The following records have been processed. Membership records with action:");
CRM_Core_Error::debug_log_message("Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action");
foreach ($processedRecords as $record) {
CRM_Core_Error::debug_log_message(implode(', ', $record));
}
}
else {
CRM_Core_Error::debug_log_message("deleteInvalidPairs() - Could not find any records to process.");
}
return $processedRecords;
}
}

View file

@ -0,0 +1,8 @@
{if $multilingual}
{foreach from=$locales item=locale}
ALTER TABLE civicrm_pcp_block ADD link_text_{$locale} varchar(255);
UPDATE civicrm_pcp_block SET link_text_{$locale} = link_text;
{/foreach}
ALTER TABLE civicrm_pcp_block DROP link_text;
{/if}

View file

@ -0,0 +1,20 @@
-- CRM-9699
{if $addDedupeEmail}
ALTER TABLE `civicrm_mailing` ADD `dedupe_email` TINYINT( 4 ) NULL DEFAULT '0' COMMENT 'Remove duplicate emails?';
{/if}
{if $worldRegionEmpty}
INSERT INTO `civicrm_worldregion` (`id`, `name`) VALUES
(1, 'Europe and Central Asia'),
(2, 'America South, Central, North and Caribbean'),
(3, 'Middle East and North Africa'),
(4, 'Asia-Pacific'),
(5, 'Africa West, East, Central and Southern'),
(99, 'unassigned');
{/if}
SELECT @region_id := max(id) from civicrm_worldregion where name = "Africa West, East, Central and Southern";
INSERT INTO `civicrm_country` (`name`, `iso_code`, `country_code`, `idd_prefix`, `ndd_prefix`, `region_id`, `is_province_abbreviated`, `address_format_id`) VALUES ('South Sudan', 'SS', NULL, NULL, NULL, @region_id, 0, NULL) ON DUPLICATE KEY UPDATE iso_code='SS';

View file

@ -0,0 +1,22 @@
-- CRM-9795 (fix duplicate option values)
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @maxValue := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @clientCaseValue := value FROM civicrm_option_value WHERE name = 'Add Client To Case' AND option_group_id = @option_group_id_act;
UPDATE civicrm_option_value SET value = @maxValue + 1 WHERE name = 'Add Client To Case' AND option_group_id = @option_group_id_act;
UPDATE civicrm_activity
INNER JOIN civicrm_case_activity ON civicrm_activity.id = civicrm_case_activity.activity_id
SET civicrm_activity.activity_type_id = @maxValue + 1
WHERE civicrm_activity.activity_type_id = @clientCaseValue;
-- CRM-9868 Force disable jobs that should only be run manually
UPDATE civicrm_job
SET is_active = 0
WHERE api_action IN ('process_membership_reminder_date','update_greeting');
UPDATE civicrm_job
SET description = '{ts escape="sql"}Sets membership renewal reminder dates for current membership records where reminder date is null. This job should never be run automatically as it will cause members to get renewal reminders repeatedly.{/ts}'
WHERE api_action = 'process_membership_reminder_date';

View file

@ -0,0 +1,5 @@
-- CRM-10264
INSERT INTO `civicrm_job`
( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
VALUES
( {$domainID}, 'Hourly', NULL, '{ts escape="sql" skip="true"}Clean-up Temporary Data and Files{/ts}','{ts escape="sql" skip="true"}Removes temporary data and files, and clears old data from cache tables. Recommend running this job every hour to help prevent database and file system bloat.{/ts}','civicrm_api3', 'job', 'cleanup', NULL, 0);

View file

@ -0,0 +1,529 @@
{include file='../CRM/Upgrade/4.1.alpha1.msg_template/civicrm_msg_template.tpl'}
-- get domain id
SELECT @domainID := min(id) FROM civicrm_domain;
-- CRM-8356
-- Add filter column 'filter' for 'civicrm_custom_field'
ALTER TABLE `civicrm_custom_field` ADD `filter` VARCHAR(255) NULL COMMENT 'Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.';
-- CRM-8062
ALTER TABLE `civicrm_subscription_history` CHANGE `status` `status` ENUM( 'Added', 'Removed', 'Pending', 'Deleted' ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'The state of the contact within the group';
-- CRM-8510
ALTER TABLE civicrm_currency
ADD UNIQUE INDEX UI_name ( name );
-- CRM-8616
DELETE FROM civicrm_currency WHERE name = 'EEK';
-- CRM-8769
INSERT IGNORE INTO civicrm_state_province
(`name`, `abbreviation`, `country_id`)
VALUES
('Metropolitan Manila' , 'MNL', '1170');
-- CRM-8902
UPDATE civicrm_navigation SET permission ='add cases,access all cases and activities', permission_operator = 'OR'
WHERE civicrm_navigation.name= 'New Case';
-- CRM-8780
-- add the settings table
CREATE TABLE `civicrm_setting` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`group_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'group name for setting element, useful in caching setting elements',
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Unique name for setting',
`value` text COLLATE utf8_unicode_ci COMMENT 'data associated with this group / name combo',
`domain_id` int(10) unsigned NOT NULL COMMENT 'Which Domain is this menu item for',
`contact_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Contact ID if the setting is localized to a contact',
`is_domain` tinyint(4) DEFAULT NULL COMMENT 'Is this setting a contact specific or site wide setting?',
`component_id` int(10) unsigned DEFAULT NULL COMMENT 'Component that this menu item belongs to',
`created_date` datetime DEFAULT NULL COMMENT 'When was the setting created',
`created_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to civicrm_contact, who created this setting',
PRIMARY KEY (`id`),
KEY `index_group_name` (`group_name`,`name`),
KEY `FK_civicrm_setting_domain_id` (`domain_id`),
KEY `FK_civicrm_setting_contact_id` (`contact_id`),
KEY `FK_civicrm_setting_component_id` (`component_id`),
KEY `FK_civicrm_setting_created_id` (`created_id`),
CONSTRAINT `FK_civicrm_setting_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_civicrm_setting_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_civicrm_setting_component_id` FOREIGN KEY (`component_id`) REFERENCES `civicrm_component` (`id`),
CONSTRAINT `FK_civicrm_setting_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- CRM-8508
SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase';
SELECT @option_group_id_activity_type := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_activity_type;
SELECT @max_wt := max(weight) from civicrm_option_value where option_group_id=@option_group_id_activity_type;
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, value, name, weight, filter, component_id)
VALUES
(@option_group_id_activity_type, {localize}'Change Custom Data'{/localize},{localize}''{/localize}, (SELECT @max_val := @max_val+1), 'Change Custom Data', (SELECT @max_wt := @max_wt+1), 0, @caseCompId);
-- CRM-8739
Update civicrm_menu set title = 'Cleanup Caches and Update Paths' where path = 'civicrm/admin/setting/updateConfigBackend';
-- CRM-8855
SELECT @option_group_id_udOpt := max(id) from civicrm_option_group where name = 'user_dashboard_options';
SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_udOpt;
SELECT @max_wt := max(weight) from civicrm_option_value where option_group_id=@option_group_id_udOpt;
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, weight, filter, is_default, component_id)
VALUES
(@option_group_id_udOpt, {localize}'Assigned Activities'{/localize}, (SELECT @max_val := @max_val+1), 'Assigned Activities', (SELECT @max_wt := @max_wt+1), 0, NULL, NULL);
-- CRM-8737
ALTER TABLE `civicrm_event` ADD `is_share` TINYINT( 4 ) NULL DEFAULT '1' COMMENT 'Can people share the event through social media?';
ALTER TABLE `civicrm_contribution_page` ADD `is_share` TINYINT(4) NULL DEFAULT '1' COMMENT 'Can people share the contribution page through social media?';
-- CRM-8357
ALTER TABLE `civicrm_contact` CHANGE `contact_sub_type` `contact_sub_type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'May be used to over-ride contact view and edit templates.';
UPDATE civicrm_contact SET contact_sub_type = CONCAT('', contact_sub_type, '');
-- CRM-6811
INSERT INTO `civicrm_dashboard`
( `domain_id`, {localize field='label'}`label`{/localize}, `url`, `permission`, `permission_operator`, `column_no`, `is_minimized`, `is_active`, `weight`, `fullscreen_url`, `is_fullscreen`, `is_reserved`)
VALUES
( @domainID, {localize}'Case Dashboard Dashlet'{/localize}, 'civicrm/dashlet/casedashboard&reset=1&snippet=4', 'access CiviCase', NULL , 0, 0, 1, 4, 'civicrm/dashlet/casedashboard&reset=1&snippet=4&context=dashletFullscreen', 1, 1);
-- CRM-9059 Admin menu rebuild
SELECT @domainID := min(id) FROM civicrm_domain;
SELECT @adminlastID := id FROM civicrm_navigation where name = 'Administer' AND domain_id = @domainID;
SELECT @customizeOld := id FROM civicrm_navigation where name = 'Customize' AND domain_id = @domainID;
SELECT @configureOld := id FROM civicrm_navigation where name = 'Configure' AND domain_id = @domainID;
SELECT @globalOld := id FROM civicrm_navigation where name = 'Global Settings' AND domain_id = @domainID;
SELECT @manageOld := id FROM civicrm_navigation where name = 'Manage' AND domain_id = @domainID;
SELECT @optionsOld := id FROM civicrm_navigation where name = 'Option Lists' AND domain_id = @domainID;
SELECT @customizeOld := id FROM civicrm_navigation where name = 'Customize' AND domain_id = @domainID;
DELETE from civicrm_navigation WHERE parent_id = @globalOld;
DELETE from civicrm_navigation WHERE parent_id IN (@customizeOld, @configureOld, @manageOld, @optionsOld);
DELETE from civicrm_navigation WHERE id IN (@customizeOld, @configureOld, @manageOld, @optionsOld);
UPDATE civicrm_navigation SET weight = 9 WHERE name = 'CiviCampaign' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 10 WHERE name = 'CiviCase' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 11 WHERE name = 'CiviContribute' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 12 WHERE name = 'CiviEvent' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 13 WHERE name = 'CiviGrant' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 14 WHERE name = 'CiviMail' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 15 WHERE name = 'CiviMember' AND parent_id = @adminlastID;
UPDATE civicrm_navigation SET weight = 16 WHERE name = 'CiviReport' AND parent_id = @adminlastID;
DELETE FROM civicrm_navigation WHERE name = 'Administration Console';
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin&reset=1', '{ts escape="sql" skip="true"}Administration Console{/ts}', 'Administration Console', 'administer CiviCRM', '', @adminlastID, '1', NULL, 1 );
SET @adminConsolelastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/configtask&reset=1', '{ts escape="sql" skip="true"}Configuration Checklist{/ts}', 'Configuration Checklist', 'administer CiviCRM', '', @adminConsolelastID, '1', NULL, 1 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Customize Data and Screens{/ts}', 'Customize Data and Screens', 'administer CiviCRM', '', @adminlastID, '1', NULL, 3 );
SET @CustomizelastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/custom/group&reset=1', '{ts escape="sql" skip="true"}Custom Fields{/ts}', 'Custom Fields', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/uf/group&reset=1', '{ts escape="sql" skip="true"}Profiles{/ts}', 'Profiles', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 2 ),
( @domainID, 'civicrm/admin/tag&reset=1', '{ts escape="sql" skip="true"}Tags (Categories){/ts}', 'Tags (Categories)', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 3 ),
( @domainID, 'civicrm/admin/options/activity_type&reset=1&group=activity_type', '{ts escape="sql" skip="true"}Activity Types{/ts}', 'Activity Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 4 ),
( @domainID, 'civicrm/admin/reltype&reset=1', '{ts escape="sql" skip="true"}Relationship Types{/ts}', 'Relationship Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/options/subtype&reset=1', '{ts escape="sql" skip="true"}Contact Types{/ts}','Contact Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 6 ),
( @domainID, 'civicrm/admin/setting/preferences/display&reset=1', '{ts escape="sql" skip="true"}Display Preferences{/ts}', 'Display Preferences', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 9 ),
( @domainID, 'civicrm/admin/setting/search&reset=1', '{ts escape="sql" skip="true"}Search Preferences{/ts}', 'Search Preferences', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 10 ),
( @domainID, 'civicrm/admin/menu&reset=1', '{ts escape="sql" skip="true"}Navigation Menu{/ts}', 'Navigation Menu', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 11 ),
( @domainID, 'civicrm/admin/options/wordreplacements&reset=1','{ts escape="sql" skip="true"}Word Replacements{/ts}','Word Replacements', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 12 ),
( @domainID, 'civicrm/admin/options/custom_search&reset=1&group=custom_search', '{ts escape="sql" skip="true"}Manage Custom Searches{/ts}', 'Manage Custom Searches', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 13 ),
( @domainID, 'civicrm/admin/extensions&reset=1', '{ts escape="sql" skip="true"}Manage Extensions{/ts}', 'Manage Extensions', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 14 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Dropdown Options{/ts}', 'Dropdown Options', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 8 );
SET @optionListlastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/options/gender&reset=1&group=gender', '{ts escape="sql" skip="true"}Gender Options{/ts}', 'Gender Options', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/options/individual_prefix&group=individual_prefix&reset=1', '{ts escape="sql" skip="true"}Individual Prefixes (Ms, Mr...){/ts}', 'Individual Prefixes (Ms, Mr...)', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 2 ),
( @domainID, 'civicrm/admin/options/individual_suffix&group=individual_suffix&reset=1', '{ts escape="sql" skip="true"}Individual Suffixes (Jr, Sr...){/ts}', 'Individual Suffixes (Jr, Sr...)', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 3 ),
( @domainID, 'civicrm/admin/options/instant_messenger_service&group=instant_messenger_service&reset=1', '{ts escape="sql" skip="true"}Instant Messenger Services{/ts}', 'Instant Messenger Services', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 4 ),
( @domainID, 'civicrm/admin/locationType&reset=1', '{ts escape="sql" skip="true"}Location Types (Home, Work...){/ts}', 'Location Types (Home, Work...)', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/options/mobile_provider&group=mobile_provider&reset=1', '{ts escape="sql" skip="true"}Mobile Phone Providers{/ts}', 'Mobile Phone Providers', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 6 ),
( @domainID, 'civicrm/admin/options/phone_type&group=phone_type&reset=1', '{ts escape="sql" skip="true"}Phone Types{/ts}', 'Phone Types', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 7 ),
( @domainID, 'civicrm/admin/options/website_type&group=website_type&reset=1', '{ts escape="sql" skip="true"}Website Types{/ts}', 'Website Types', 'administer CiviCRM', '', @optionListlastID, '1', NULL, 8 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Communications{/ts}', 'Communications', 'administer CiviCRM', '', @adminlastID, '1', NULL, 4 );
SET @communicationslastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/domain&action=update&reset=1', '{ts escape="sql" skip="true"}Organization Address and Contact Info{/ts}', 'Organization Address and Contact Info', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/options/from_email_address&group=from_email_address&reset=1', '{ts escape="sql" skip="true"}FROM Email Addresses{/ts}', 'FROM Email Addresses', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 2 ),
( @domainID, 'civicrm/admin/messageTemplates&reset=1', '{ts escape="sql" skip="true"}Message Templates{/ts}', 'Message Templates', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 3 ),
( @domainID, 'civicrm/admin/scheduleReminders&reset=1', '{ts escape="sql" skip="true"}Schedule Reminders{/ts}', 'Schedule Reminders', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 4 ),
( @domainID, 'civicrm/admin/options/preferred_communication_method&group=preferred_communication_method&reset=1', '{ts escape="sql" skip="true"}Preferred Communication Methods{/ts}', 'Preferred Communication Methods', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/labelFormats&reset=1', '{ts escape="sql" skip="true"}Label Formats{/ts}', 'Label Formats', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 6 ),
( @domainID, 'civicrm/admin/pdfFormats&reset=1', '{ts escape="sql" skip="true"}Print Page (PDF) Formats{/ts}', 'Print Page (PDF) Formats', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 7 ),
( @domainID, 'civicrm/admin/options/email_greeting&group=email_greeting&reset=1', '{ts escape="sql" skip="true"}Email Greeting Formats{/ts}', 'Email Greeting Formats', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 8 ),
( @domainID, 'civicrm/admin/options/postal_greeting&group=postal_greeting&reset=1', '{ts escape="sql" skip="true"}Postal Greeting Formats{/ts}', 'Postal Greeting Formats', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 9 ),
( @domainID, 'civicrm/admin/options/addressee&group=addressee&reset=1', '{ts escape="sql" skip="true"}Addressee Formats{/ts}', 'Addressee Formats', 'administer CiviCRM', '', @communicationslastID, '1', NULL, 10 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Localization{/ts}', 'Localization', 'administer CiviCRM', '', @adminlastID, '1', NULL, 6 );
SET @locallastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/setting/localization&reset=1', '{ts escape="sql" skip="true"}Languages, Currency, Locations{/ts}', 'Languages, Currency, Locations', 'administer CiviCRM', '', @locallastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/setting/preferences/address&reset=1', '{ts escape="sql" skip="true"}Address Settings{/ts}', 'Address Settings', 'administer CiviCRM', '', @locallastID, '1', NULL, 2 ),
( @domainID, 'civicrm/admin/setting/date&reset=1', '{ts escape="sql" skip="true"}Date Format{/ts}', 'Date Formats', 'administer CiviCRM', '', @locallastID, '1', NULL, 3 ),
( @domainID, 'civicrm/admin/options/languages&group=languages&reset=1', '{ts escape="sql" skip="true"}Preferred Language Options{/ts}', 'Preferred Language Options', 'administer CiviCRM', '', @locallastID, '1', NULL, 4 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Users and Permissions{/ts}', 'Users and Permissions', 'administer CiviCRM', '', @adminlastID, '1', NULL, 7 );
SET @usersPermslastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/access&reset=1', '{ts escape="sql" skip="true"}Permissions (Access Control){/ts}', 'Permissions (Access Control)', 'administer CiviCRM', '', @usersPermslastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/synchUser&reset=1', '{ts escape="sql" skip="true"}Synchronize Users to Contacts{/ts}', 'Synchronize Users to Contacts', 'administer CiviCRM', '', @usersPermslastID, '1', NULL, 2 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}System Settings{/ts}', 'System Settings', 'administer CiviCRM', '', @adminlastID, '1', NULL, 8 );
SET @systemSettingslastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/setting/component&reset=1', '{ts escape="sql" skip="true"}Enable CiviCRM Components{/ts}', 'Enable Components', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 1 ),
( @domainID, 'civicrm/admin/setting/smtp&reset=1', '{ts escape="sql" skip="true"}Outbound Email (SMTP/Sendmail){/ts}', 'Outbound Email', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 2 ),
( @domainID, 'civicrm/admin/paymentProcessor&reset=1', '{ts escape="sql" skip="true"}Payment Processors{/ts}', 'Payment Processors', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 3 ),
( @domainID, 'civicrm/admin/setting/mapping&reset=1', '{ts escape="sql" skip="true"}Mapping and Geocoding{/ts}', 'Mapping and Geocoding', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 4 ),
( @domainID, 'civicrm/admin/setting/misc&reset=1', '{ts escape="sql" skip="true"}Undelete, Logging and ReCAPTCHA{/ts}', 'Undelete, Logging and ReCAPTCHA', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/setting/path&reset=1', '{ts escape="sql" skip="true"}Directories{/ts}', 'Directories', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 6 ),
( @domainID, 'civicrm/admin/setting/url&reset=1', '{ts escape="sql" skip="true"}Resource URLs{/ts}', 'Resource URLs', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 7 ),
( @domainID, 'civicrm/admin/setting/updateConfigBackend&reset=1', '{ts escape="sql" skip="true"}Cleanup Caches and Update Paths{/ts}', 'Cleanup Caches and Update Paths', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 8 ),
( @domainID, 'civicrm/admin/setting/uf&reset=1', '{ts escape="sql" skip="true"}CMS Database Integration{/ts}', 'CMS Integration', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 9 ),
( @domainID, 'civicrm/admin/options/safe_file_extension&group=safe_file_extension&reset=1', '{ts escape="sql" skip="true"}Safe File Extensions{/ts}', 'Safe File Extensions','administer CiviCRM', '',@systemSettingslastID, '1', NULL, 10 ),
( @domainID, 'civicrm/admin/options?reset=1', '{ts escape="sql" skip="true"}Option Groups{/ts}', 'Option Groups', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 11 ),
( @domainID, 'civicrm/admin/mapping&reset=1', '{ts escape="sql" skip="true"}Import/Export Mappings{/ts}', 'Import/Export Mappings', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 12 ),
( @domainID, 'civicrm/admin/setting/debug&reset=1', '{ts escape="sql" skip="true"}Debugging and Error Handling{/ts}','Debugging and Error Handling', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 13 ),
( @domainID, 'civicrm/admin/setting/preferences/multisite&reset=1', '{ts escape="sql" skip="true"}Multi Site Settings{/ts}', 'Multi Site Settings', 'administer CiviCRM', '', @systemSettingslastID, '1', NULL, 14 );
SELECT @campaignAdminID := id FROM civicrm_navigation where name = 'CiviCampaign' AND parent_id = @adminlastID;
SELECT @eventAdminID := id FROM civicrm_navigation where name = 'CiviEvent' AND parent_id = @adminlastID;
SELECT @mailAdminID := id FROM civicrm_navigation where name = 'CiviMail' AND parent_id = @adminlastID;
SELECT @memberAdminID := id FROM civicrm_navigation where name = 'CiviMember' AND parent_id = @adminlastID;
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/setting/preferences/campaign&reset=1', '{ts escape="sql" skip="true"}CiviCampaign Component Settings{/ts}', 'CiviCampaign Component Settings','administer CiviCampaign', '', @campaignAdminID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/setting/preferences/event&reset=1', '{ts escape="sql" skip="true"}CiviEvent Component Settings{/ts}', 'CiviEvent Component Settings','access CiviEvent,administer CiviCRM', 'AND', @eventAdminID, '1', NULL, 13 ),
( @domainID, 'civicrm/admin/setting/preferences/mailing&reset=1', '{ts escape="sql" skip="true"}CiviMail Component Settings{/ts}', 'CiviMail Component Settings','access CiviMail,administer CiviCRM', 'AND', @mailAdminID, '1', NULL, 6 ),
( @domainID, 'civicrm/admin/setting/preferences/member&reset=1', '{ts escape="sql" skip="true"}CiviMember Component Settings{/ts}', 'CiviMember Component Settings','access CiviMember,administer CiviCRM', 'AND', @memberAdminID, '1', NULL, 5 ),
( @domainID, 'civicrm/admin/options/event_badge&group=event_badge&reset=1', '{ts escape="sql" skip="true"}Event Badge Formats{/ts}', 'Event Badge Formats', 'access CiviEvent,administer CiviCRM', 'AND', @eventAdminID, '1', NULL, 11 );
-- CRM-9113
ALTER TABLE `civicrm_report_instance` ADD `grouprole` VARCHAR( 1024 ) NULL AFTER `permission`;
-- CRM-8762 Fix option_group table
ALTER TABLE civicrm_option_group CHANGE `is_reserved` `is_reserved` TINYINT DEFAULT 1;
UPDATE civicrm_option_group SET `is_reserved` = 1;
{if $multilingual}
{foreach from=$locales item=locale}
UPDATE civicrm_option_group SET label_{$locale} = description_{$locale} WHERE label_{$locale} IS NULL;
{/foreach}
{else}
UPDATE civicrm_option_group SET `label` = `description` WHERE `label` IS NULL;
{/if}
-- CRM-9112
ALTER TABLE `civicrm_dedupe_rule_group` ADD `title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Label of the rule group';
ALTER TABLE `civicrm_dedupe_rule_group` ADD `is_reserved` TINYINT( 4 ) NULL DEFAULT NULL COMMENT 'Is this a reserved rule - a rule group that has been optimized and cannot be changed by the admin';
UPDATE `civicrm_dedupe_rule_group` SET `name` = CONCAT( REPLACE( `name`, '-', '' ), '-', id );
-- the fuzzy default dedupe rules
INSERT INTO civicrm_dedupe_rule_group (contact_type, threshold, level, is_default, name, title, is_reserved)
VALUES ('Individual', 20, 'Fuzzy', 1, 'IndividualFuzzy', 'Individual Fuzzy In-built', 1);
SELECT @drgid := MAX(id) FROM civicrm_dedupe_rule_group;
INSERT INTO civicrm_dedupe_rule (dedupe_rule_group_id, rule_table, rule_field, rule_weight)
VALUES (@drgid, 'civicrm_contact', 'first_name', 5),
(@drgid, 'civicrm_contact', 'last_name', 7),
(@drgid, 'civicrm_email' , 'email', 10);
-- the strict dedupe rules
INSERT INTO civicrm_dedupe_rule_group (contact_type, threshold, level, is_default, name, title, is_reserved)
VALUES ('Individual', 10, 'Strict', 1, 'IndividualStrict', 'Individual Strict In-built', 1);
SELECT @drgid := MAX(id) FROM civicrm_dedupe_rule_group;
INSERT INTO civicrm_dedupe_rule (dedupe_rule_group_id, rule_table, rule_field, rule_weight)
VALUES (@drgid, 'civicrm_email', 'email', 10);
INSERT INTO civicrm_dedupe_rule_group (contact_type, threshold, level, is_default, name, title, is_reserved)
VALUES ('Individual', 15, 'Strict', 0, 'IndividualComplete', 'Individual Complete Inbuilt', 1);
SELECT @drgid := MAX(id) FROM civicrm_dedupe_rule_group;
INSERT INTO civicrm_dedupe_rule (dedupe_rule_group_id, rule_table, rule_field, rule_weight)
VALUES (@drgid, 'civicrm_contact', 'first_name', '5'),
(@drgid, 'civicrm_contact', 'last_name', '5'),
(@drgid, 'civicrm_address', 'street_address', '5'),
(@drgid, 'civicrm_contact', 'middle_name', '1'),
(@drgid, 'civicrm_contact', 'suffix_id', '1');
-- CRM-9120
{if $multilingual}
{foreach from=$locales item=locale}
ALTER TABLE `civicrm_location_type` ADD display_name_{$locale} VARCHAR( 64 ) DEFAULT NULL COMMENT 'Location Type Display Name.' AFTER `name`;
UPDATE `civicrm_location_type` SET display_name_{$locale} = `name`;
{/foreach}
{else}
ALTER TABLE `civicrm_location_type` ADD `display_name` VARCHAR( 64 ) DEFAULT NULL COMMENT 'Location Type Display Name.' AFTER `name`;
UPDATE `civicrm_location_type` SET `display_name` = `name`;
{/if}
-- CRM-9125
ALTER TABLE `civicrm_contribution_recur` ADD `contribution_type_id` int(10) unsigned NULL COMMENT 'FK to Contribution Type';
ALTER TABLE `civicrm_contribution_recur` ADD CONSTRAINT `FK_civicrm_contribution_recur_contribution_type_id` FOREIGN KEY (`contribution_type_id`) REFERENCES `civicrm_contribution_type` (`id`) ON DELETE SET NULL;
ALTER TABLE `civicrm_contribution_recur` ADD `payment_instrument_id` int(10) unsigned NULL COMMENT 'FK to Payment Instrument';
ALTER TABLE `civicrm_contribution_recur` ADD INDEX UI_contribution_recur_payment_instrument_id ( payment_instrument_id );
ALTER TABLE `civicrm_contribution_recur` ADD `campaign_id` int(10) unsigned NULL COMMENT 'The campaign for which this contribution has been triggered.';
ALTER TABLE `civicrm_contribution_recur` ADD CONSTRAINT `FK_civicrm_contribution_recur_campaign_id` FOREIGN KEY (`campaign_id`) REFERENCES `civicrm_campaign` (`id`) ON DELETE SET NULL;
UPDATE `civicrm_contribution_recur` ccr INNER JOIN `civicrm_contribution` cc ON ccr.id = cc.contribution_recur_id SET ccr.campaign_id = cc.campaign_id, ccr.payment_instrument_id = cc.payment_instrument_id, ccr.contribution_type_id = cc.contribution_type_id;
-- CRM-8962
INSERT INTO civicrm_action_mapping ( entity, entity_value, entity_value_label, entity_status, entity_status_label, entity_date_start, entity_date_end, entity_recipient )
VALUES
('civicrm_participant', 'event_type', 'Event Type', 'civicrm_participant_status_type', 'Participant Status', 'event_start_date', 'event_end_date', 'event_contacts'),
('civicrm_participant', 'civicrm_event', 'Event Name', 'civicrm_participant_status_type', 'Participant Status', 'event_start_date', 'event_end_date', 'event_contacts');
INSERT INTO civicrm_option_group
(name, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, is_reserved, is_active)
VALUES
('event_contacts', {localize}'{ts escape="sql"}Event Recipients{/ts}'{/localize}, {localize}'{ts escape="sql"}Event Recipients{/ts}'{/localize}, 1, 1),
('contact_reference_options', {localize}'{ts escape="sql"}Contact Reference Autocomplete Options{/ts}'{/localize}, {localize}'{ts escape="sql"}Contact Reference Autocomplete Options{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_ere := max(id) from civicrm_option_group where name = 'event_contacts';
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, filter, weight, is_active )
VALUES
(@option_group_id_ere, {localize}'{ts escape="sql"}Participant Role{/ts}'{/localize}, 1, 'participant_role', 0, 1, 1 );
ALTER TABLE civicrm_action_schedule ADD `absolute_date` date DEFAULT NULL COMMENT 'Date on which the reminder be sent.';
ALTER TABLE civicrm_action_schedule ADD `recipient_listing` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'listing based on recipient field.';
-- CRM-8534
ALTER TABLE civicrm_pcp_block
DROP FOREIGN KEY FK_civicrm_pcp_block_entity_id,
DROP INDEX FK_civicrm_pcp_block_entity_id;
ALTER TABLE civicrm_pcp
DROP FOREIGN KEY FK_civicrm_pcp_contribution_page_id,
DROP INDEX FK_civicrm_pcp_contribution_page_id;
ALTER TABLE `civicrm_pcp`
ADD `page_type` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'contribute' AFTER `contribution_page_id`;
ALTER TABLE `civicrm_pcp`
CHANGE `contribution_page_id` `page_id` INT( 10 ) UNSIGNED NOT NULL COMMENT 'The Page which triggered this pcp';
ALTER TABLE `civicrm_pcp`
ADD `pcp_block_id` int(10) unsigned NOT NULL COMMENT 'The pcp block that this pcp page was created from' AFTER `page_type`;
UPDATE `civicrm_pcp`
SET `page_type` = 'contribute' WHERE `page_type` = '' OR `page_type` IS NULL;
UPDATE `civicrm_pcp` `pcp`
SET `pcp_block_id` = (SELECT `id` FROM `civicrm_pcp_block` `pb` WHERE `pb`.`entity_id` = `pcp`.`page_id`);
ALTER TABLE `civicrm_pcp_block`
ADD `target_entity_type` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'contribute' AFTER `entity_id`;
ALTER TABLE `civicrm_pcp_block`
ADD `target_entity_id` int(10) unsigned NOT NULL COMMENT 'The entity that this pcp targets' AFTER `target_entity_type`;
UPDATE `civicrm_pcp_block`
SET `target_entity_id` = `entity_id` WHERE `target_entity_id` = '' OR `target_entity_id` IS NULL;
ALTER TABLE `civicrm_pcp` DROP COLUMN `referer`;
UPDATE civicrm_navigation SET url = 'civicrm/admin/pcp?reset=1&page_type=contribute' WHERE url = 'civicrm/admin/pcp&reset=1';
SELECT @lastEventId := MAX(id) FROM civicrm_navigation where name = 'Events' AND domain_id = @domainID;
SELECT @adminEventId := MAX(id) FROM civicrm_navigation where name = 'CiviEvent' AND domain_id = @domainID;
SELECT @lastEventIdWeight := MAX(weight)+1 FROM civicrm_navigation where parent_id = @lastEventId;
SELECT @adminEventIdWeight := MAX(weight)+1 FROM civicrm_navigation where parent_id = @adminEventId;
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/pcp?reset=1&page_type=event', '{ts escape="sql" skip="true"}Personal Campaign Pages{/ts}', 'Personal Campaign Pages', 'access CiviEvent,administer CiviCRM', 'AND', @lastEventId, '1', 1, @lastEventIdWeight ),
( @domainID, 'civicrm/admin/pcp?reset=1&page_type=event', '{ts escape="sql" skip="true"}Personal Campaign Pages{/ts}', 'Personal Campaign Pages', 'access CiviEvent,administer CiviCRM', 'AND', @adminEventId, '1', 1, @adminEventIdWeight );
-- CRM-8358 - consolidated cron jobs
CREATE TABLE `civicrm_job` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Job Id',
`domain_id` int(10) unsigned NOT NULL COMMENT 'Which Domain is this scheduled job for',
`run_frequency` enum('Hourly','Daily','Always') COLLATE utf8_unicode_ci DEFAULT 'Daily' COMMENT 'Scheduled job run frequency.',
`last_run` datetime DEFAULT NULL COMMENT 'When was this cron entry last run',
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Title of the job',
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Description of the job',
`api_prefix` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Prefix of the job api call',
`api_entity` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Entity of the job api call',
`api_action` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Action of the job api call',
`parameters` text COLLATE utf8_unicode_ci COMMENT 'List of parameters to the command.',
`is_active` tinyint(4) DEFAULT NULL COMMENT 'Is this job active?',
PRIMARY KEY (`id`),
KEY `FK_civicrm_job_domain_id` (`domain_id`),
CONSTRAINT `FK_civicrm_job_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `civicrm_job_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Job log entry Id',
`domain_id` int(10) unsigned NOT NULL COMMENT 'Which Domain is this scheduled job for',
`run_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Log entry date',
`job_id` int(10) unsigned DEFAULT NULL COMMENT 'Pointer to job id - not a FK though, just for logging purposes',
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Title of the job',
`command` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Full path to file containing job script',
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Title line of log entry',
`data` text COLLATE utf8_unicode_ci COMMENT 'Potential extended data for specific job run (e.g. tracebacks).',
PRIMARY KEY (`id`),
KEY `FK_civicrm_job_log_domain_id` (`domain_id`),
CONSTRAINT `FK_civicrm_job_log_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `civicrm_job`
( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
VALUES
( @domainID, 'Hourly' , NULL, '{ts escape="sql" skip="true"}Mailings scheduler{/ts}', '{ts escape="sql" skip="true"}Sends out scheduled mailings{/ts}', 'civicrm_api3', 'job', 'process_mailing', 'user=USERNAME\r\npassword=PASSWORD\r\nkey=SITE_KEY', 0),
( @domainID, 'Hourly' , NULL, '{ts escape="sql" skip="true"}Bounces fetcher{/ts}', '{ts escape="sql" skip="true"}Fetches bounces from mailings and writes them to mailing statistics{/ts}', 'civicrm_api3', 'job', 'fetch_bounces', 'user=USERNAME\r\npassword=PASSWORD\r\nkey=SITE_KEY', 0),
( @domainID, 'Hourly' , NULL, '{ts escape="sql" skip="true"}Activity processor{/ts}', '{ts escape="sql" skip="true"}{/ts}', 'civicrm_api3', 'job', 'fetch_activities', 'user=USERNAME\r\npassword=PASSWORD\r\nkey=SITE_KEY', 0),
( @domainID, 'Daily' , NULL, '{ts escape="sql" skip="true"}Pledge record processor{/ts}', '{ts escape="sql" skip="true"}Updates pledge records and sends out reminders{/ts}', 'civicrm_api3', 'job', 'process_pledge', 'version=3\r\n', 0),
( @domainID, 'Daily' , NULL, '{ts escape="sql" skip="true"}Address geocoder{/ts}', '{ts escape="sql" skip="true"}Goes through addresses and geocodes them (requires Geocoding API on){/ts}', 'civicrm_api3', 'job', 'geocode', 'version=3\r\n', 0),
( @domainID, 'Daily' , NULL, '{ts escape="sql" skip="true"}Greeting updater{/ts}', '{ts escape="sql" skip="true"}Goes through contact records and updates greeting settings{/ts}', 'civicrm_api3', 'job', 'update_greeting', 'version=3\r\n', 0),
( @domainID, 'Daily' , NULL, '{ts escape="sql" skip="true"}Report sender{/ts}', '{ts escape="sql" skip="true"}Generates and sends out reports via email{/ts}', 'civicrm_api3', 'job', 'mail_reports', 'version=3\r\n', 0),
( @domainID, 'Daily' , NULL, '{ts escape="sql" skip="true"}Scheduled reminders sender{/ts}', '{ts escape="sql" skip="true"}Sends out scheduled reminders via email.{/ts}', 'civicrm_api3', 'job', 'send_reminder', 'version=3\r\n', 0),
( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Participant status processor{/ts}','{ts escape="sql" skip="true"}Adjusts event participant statuses based on time{/ts}', 'civicrm_api3', 'job', 'process_participant', 'version=3\r\n', 0),
( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Membership status processor{/ts}', '{ts escape="sql" skip="true"}Adjusts event membership statuses based on time{/ts}', 'civicrm_api3', 'job', 'process_membership', 'version=3\r\n', 0),
( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Membership reminder date processor{/ts}','{ts escape="sql" skip="true"}Adjusts membership reminder dates based on time{/ts}', 'civicrm_api3', 'job', 'process_process_membership_reminder_date', 'version=3\r\n', 0);
--CRM 9135
ALTER TABLE civicrm_contribution_recur
ADD is_email_receipt TINYINT (4) COMMENT 'if true, receipt is automatically emailed to contact on each successful payment' AFTER payment_processor_id;
-- /***** Civicrm Multi-Event Registration ***********/
CREATE TABLE civicrm_event_carts (
id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Cart Id',
user_id int unsigned COMMENT 'FK to civicrm_contact who created this cart',
coupon_code varchar(255) DEFAULT NULL,
completed tinyint DEFAULT 0,
PRIMARY KEY ( id ),
CONSTRAINT FK_civicrm_event_carts_user_id FOREIGN KEY (user_id)
REFERENCES civicrm_contact(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
CREATE TABLE civicrm_events_in_carts (
id int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Event In Cart Id',
event_id int unsigned COMMENT 'FK to Event ID',
event_cart_id int unsigned COMMENT 'FK to Event Cart ID',
PRIMARY KEY ( id ),
CONSTRAINT FK_civicrm_events_in_carts_event_id FOREIGN KEY (event_id)
REFERENCES civicrm_event(id) ON DELETE CASCADE,
CONSTRAINT FK_civicrm_events_in_carts_event_cart_id FOREIGN KEY
(event_cart_id) REFERENCES civicrm_event_carts(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
ALTER TABLE civicrm_participant
ADD discount_amount int unsigned DEFAULT 0 COMMENT 'Discount Amount';
ALTER TABLE civicrm_participant
ADD cart_id int unsigned DEFAULT NULL COMMENT 'FK to civicrm_event_carts';
ALTER TABLE civicrm_participant
ADD CONSTRAINT FK_civicrm_participant_cart_id FOREIGN KEY (cart_id)
REFERENCES civicrm_event_carts(id) ON DELETE SET NULL;
-- XXX a hint to the payment form. Can someone make this go away?
ALTER TABLE civicrm_participant
ADD must_wait TINYINT DEFAULT 0 COMMENT 'On Waiting List';
SELECT @pending_id := MAX(id) + 1 FROM civicrm_participant_status_type;
INSERT INTO civicrm_participant_status_type
(id, name, {localize field='label'}label{/localize}, class, is_reserved, is_active, is_counted, weight, visibility_id)
VALUES
(@pending_id, 'Pending in cart', {localize}'{ts escape="sql"}Pending in cart{/ts}'{/localize}, 'Pending', 1, 1, 0, @pending_id, 2 );
ALTER TABLE civicrm_event
ADD parent_event_id int unsigned DEFAULT NULL COMMENT 'Implicit FK to civicrm_event: parent event';
ALTER TABLE civicrm_event
ADD slot_label_id int unsigned DEFAULT NULL COMMENT 'Subevent slot label. Implicit FK to civicrm_option_value where option_group = conference_slot.';
INSERT INTO
`civicrm_option_group` (`name`, {localize field='label'}`label`{/localize}, {localize field='description'}`description`{/localize}, `is_reserved`, `is_active`)
VALUES
('conference_slot' , {localize}'{ts escape="sql"}Conference Slot{/ts}'{/localize}, {localize}'{ts escape="sql"}Conference Slot{/ts}'{/localize} , 1, 1);
SELECT @option_group_id_conference_slot := max(id) from civicrm_option_group where name = 'conference_slot';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_conference_slot, {localize}'{ts escape="sql"}Morning Sessions{/ts}'{/localize}, 1, '{ts escape="sql"}Morning Sessions{/ts}', NULL, 0, NULL, 1, {localize}'{ts escape="sql"}NULL{/ts}'{/localize}, 0, 0, 1, NULL, NULL),
(@option_group_id_conference_slot, {localize}'{ts escape="sql"}Evening Sessions{/ts}'{/localize}, 2, '{ts escape="sql"}Evening Sessions{/ts}', NULL, 0, NULL, 2, {localize}'{ts escape="sql"}NULL{/ts}'{/localize}, 0, 0, 1, NULL, NULL);
SELECT @msg_tpl_workflow_event := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_event';
SELECT @weight := MAX(weight) + 1 FROM civicrm_option_value WHERE option_group_id = @msg_tpl_workflow_event;
INSERT INTO civicrm_option_value
(option_group_id, name, {localize field='label'}label{/localize}, value, weight)
VALUES
(@msg_tpl_workflow_event, 'event_registration_receipt', {localize}'{ts escape="sql"}Events - Receipt only{/ts}'{/localize}, @weight, @weight);
{* SELECT @tpl_ovid_$vName := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_$gName AND name = '$vName'; *}
{* INSERT INTO civicrm_msg_template *}
-- CRM-8532
UPDATE `civicrm_dashboard` SET url = REPLACE( url, 'snippet=4', 'snippet=5' ), fullscreen_url = REPLACE( fullscreen_url, 'snippet=4', 'snippet=5' );
{if $multilingual}
{foreach from=$locales item=locale}
ALTER TABLE civicrm_option_group CHANGE label_{$locale} title_{$locale} varchar(255);
{/foreach}
{else}
ALTER TABLE civicrm_option_group CHANGE label title varchar(255);
{/if}

View file

@ -0,0 +1,12 @@
-- CRM-8356 added missing option values
SELECT @option_group_id_acConRef := max(id) from civicrm_option_group where name = 'contact_reference_options';
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, filter, weight, is_active )
VALUES
(@option_group_id_acConRef, {localize}'{ts escape="sql"}Email Address{/ts}'{/localize} , 2, 'email' , 0, 2, 1 ),
(@option_group_id_acConRef, {localize}'{ts escape="sql"}Phone{/ts}'{/localize} , 3, 'phone' , 0, 3, 1 ),
(@option_group_id_acConRef, {localize}'{ts escape="sql"}Street Address{/ts}'{/localize} , 4, 'street_address', 0, 4, 1 ),
(@option_group_id_acConRef, {localize}'{ts escape="sql"}City{/ts}'{/localize} , 5, 'city' , 0, 5, 1 ),
(@option_group_id_acConRef, {localize}'{ts escape="sql"}State/Province{/ts}'{/localize} , 6, 'state_province', 0, 6, 1 ),
(@option_group_id_acConRef, {localize}'{ts escape="sql"}Country{/ts}'{/localize} , 7, 'country' , 0, 7, 1 );

View file

@ -0,0 +1,11 @@
{if $addWightForActivity}
ALTER TABLE `civicrm_activity` ADD weight INT( 11 ) NULL DEFAULT NULL;
{/if}
-- CRM-8508
SELECT @option_group_id_cgeo := max(id) from civicrm_option_group where name = 'cg_extend_objects';
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, grouping, filter, is_default, weight, {localize field='description'}description{/localize}, is_optgroup, is_reserved, is_active, component_id, visibility_id)
VALUES
(@option_group_id_cgeo, {localize}'{ts escape="sql"}Cases{/ts}'{/localize}, 'Case', 'civicrm_case', NULL, 0, NULL, 2, {localize}'CRM_Case_PseudoConstant::caseType;'{/localize}, 0, 0, 1, NULL, NULL);

View file

@ -0,0 +1,119 @@
-- CRM-9384 Add sample CiviMail Newsletter Message Template
INSERT INTO civicrm_msg_template
(msg_title, msg_subject, msg_text, msg_html, workflow_id, is_default, is_reserved)
VALUES
('Sample CiviMail Newsletter Template', 'Sample CiviMail Newsletter', '', '<table width=612 cellpadding=0 cellspacing=0 bgcolor="#f4fff4">
<tr>
<td colspan="2" bgcolor="#ffffff" valign="middle" >
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td>
<a href="http://www.YOUR-SITE.org"><img src="http://drupal.demo.civicrm.org/files/garland_logo.png" border=0 alt="Replace this logo with the URL to your own"></a>
</td>
<td>&nbsp; &nbsp;</td>
<td>
<a href="http://www.YOUR-SITE.org" style="text-decoration: none;"><font size=5 face="Arial, Verdana, sans-serif" color="#8bc539">Your Newsletter Title</font></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<!-- left column -->
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td style="font-family: Arial, Verdana, sans-serif; font-size: 12px;" >
<font face="Arial, Verdana, sans-serif" size="2" >
Greetings {literal}{contact.display_name}{/literal},
<br /><br />
This is a sample template designed to help you get started creating and sending your own CiviMail messages. This template uses an HTML layout that is generally compatible with the wide variety of email clients that your recipients might be using (e.g. Gmail, Outlook, Yahoo, etc.).
<br /><br />You can select this "Sample CiviMail Newsletter Template" from the "Use Template" drop-down in Step 3 of creating a mailing, and customize it to your needs. Then check the "Save as New Template" box on the bottom the page to save your customized version for use in future mailings.
<br /><br />The logo you use must be uploaded to your server. Copy and paste the URL path to the logo into the &lt;img src= tag in the HTML at the top. Click "Source" or the Image button if you are using the text editor.
<br /><br />
Edit the color of the links and headers using the color button or by editing the HTML.
<br /><br />
Your newsletter message and donation appeal can go here. Click the link button to <a href="#">create links</a> - remember to use a fully qualified URL starting with http:// in all your links!
<br /><br />
To use CiviMail:
<ul>
<li><a href="http://book.civicrm.org/user/initial-set-up/email-system-configuration">Configure your Email System</a>.</li>
<li>Make sure your web hosting provider allows outgoing bulk mail, and see if they have a restriction on quantity. If they don\'t allow bulk mail, consider <a href="http://wiki.civicrm.org/confluence/display/CRM/Hosting+provider+information">finding a new host</a>.</li>
</ul>
Sincerely,
<br /><br />
Your Team
</font>
</td>
</tr>
</table>
</td>
<td valign="top" bgcolor="#f3f3ff" >
<!-- right column -->
<table width=180 cellpadding=10 cellspacing=0 border=0>
<tr>
<td style="color: #000; font-family: Arial, Verdana, sans-serif; font-size: 12px;" >
<font face="Arial, Verdana, sans-serif" size="2" >
<font color="#003399"><strong>Featured Events</strong> </font><br />
Fundraising Dinner<br />
Training Meeting<br />
Board of Directors Annual Meeting<br />
<br /><br />
<font color="#003399"><strong>Community Events</strong></font><br />
Bake Sale<br />
Charity Auction<br />
Art Exhibit<br />
<br /><br />
<font color="#003399"><strong>Important Dates</strong></font><br />
Tuesday August 27<br />
Wednesday September 8<br />
Thursday September 29<br />
Saturday October 1<br />
Sunday October 20<br />
</font>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td>
<font face="Arial, Verdana, sans-serif" size="2" >
<font color="#8bc539"><strong>Helpful Tips</strong></font>
<br /><br />
<font color="#3b5187">Tokens</font><br />
Click "Insert Tokens" to dynamically insert names, addresses, and other contact data of your recipients.
<br /><br />
<font color="#3b5187">Plain Text Version</font><br />
Some people refuse HTML emails altogether. We recommend sending a plain-text version of your important communications to accommodate them. Luckily, CiviCRM accommodates for this! Just click "Plain Text" and copy and paste in some text. Line breaks (carriage returns) and fully qualified URLs like http://www.example.com are all you get, no HTML here!
<br /><br />
<font color="#3b5187">Play by the Rules</font><br />
The address of the sender is required by the Can Spam Act law. This is an available token called domain.address. An unsubscribe or opt-out link is also required. There are several available tokens for this. <em>{literal}{action.optOutUrl}{/literal}</em> creates a link for recipients to click if they want to opt out of receiving emails from your organization. <em>{literal}{action.unsubscribeUrl}{/literal}</em> creates a link to unsubscribe from the specific mailing list used to send this message. Click on "Insert Tokens" to find these and look for tokens named "Domain" or "Unsubscribe". This sample template includes both required tokens at the bottom of the message. You can also configure a default Mailing Footer containing these tokens.
<br /><br />
<font color="#3b5187">Composing Offline</font><br />
If you prefer to compose an HTML email offline in your own text editor, you can upload this HTML content into CiviMail or simply click "Source" and then copy and paste the HTML in.
<br /><br />
<font color="#3b5187">Images</font><br />
Most email clients these days (Outlook, Gmail, etc) block image loading by default. This is to protect their users from annoying or harmful email. Not much we can do about this, so encourage recipients to add you to their contacts or "whitelist". Also use images sparingly, do not rely on images to convey vital information, and always use HTML "alt" tags which describe the image content.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" style="color: #000; font-family: Arial, Verdana, sans-serif; font-size: 10px;">
<font face="Arial, Verdana, sans-serif" size="2" >
<hr>
<a href="{literal}{action.unsubscribeUrl}{/literal}" title="click to unsubscribe">Click here</a> to unsubscribe from this mailing list.<br /><br />
Our mailing address is:<br />
{literal}{domain.address}{/literal}
</td>
</tr>
</table>', NULL, 1, 0);

View file

@ -0,0 +1,33 @@
-- Fix invalid api actions in Job table and insert missing job
UPDATE `civicrm_job`
SET api_action = 'process_membership_reminder_date' WHERE api_action = 'process_process_membership_reminder_date';
UPDATE `civicrm_job`
SET api_action = 'mail_report' WHERE api_action = 'mail_reports';
SELECT @domainID := min(id) FROM civicrm_domain;
INSERT INTO `civicrm_job`
( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
VALUES
( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Process Survey Respondents{/ts}', '{ts escape="sql" skip="true"}Releases reserved survey respondents when they have been reserved for longer than the Release Frequency days specified for that survey.{/ts}','civicrm_api3', 'job', 'process_respondent','version=3\r\n', 0);
-- Job table was initially delivered with invalid and not-used parameters. Clearing them out. Most jobs do not need any parameters.
UPDATE `civicrm_job`
SET parameters = NULL;
-- Insert Schedule Jobs admin menu item
SELECT @systemSettingsID := id FROM civicrm_navigation where name = 'System Settings' AND domain_id = @domainID;
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/admin/job&reset=1', '{ts escape="sql" skip="true"}Scheduled Jobs{/ts}', 'Scheduled Jobs', 'administer CiviCRM', '', @systemSettingsID, '1', NULL, 15 );
-- CRM-9468
-- update Serbia/Montenegro provinces
UPDATE civicrm_state_province SET country_id = 1243 WHERE id = 5112;
UPDATE civicrm_state_province SET country_id = 1242 WHERE id = 5113;
UPDATE civicrm_state_province SET country_id = 1242 WHERE id = 5114;
UPDATE civicrm_state_province SET country_id = 1242 WHERE id = 5115;
-- CRM-9523
ALTER TABLE `civicrm_note` MODIFY `privacy` VARCHAR(255) COMMENT 'Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)';

View file

@ -0,0 +1,34 @@
-- CRM-10641 (fix duplicate option values)
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @maxValue := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @clientSMSValue := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
SELECT @smsVal := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_act GROUP BY value
HAVING count(value) > 1 AND value = @clientSMSValue;
UPDATE civicrm_option_value
SET value = @maxValue + 1
WHERE value = @smsVal
AND name = 'BULK SMS' AND option_group_id = @option_group_id_act;
SELECT @newClientSMSValue := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
UPDATE civicrm_activity
INNER JOIN civicrm_mailing ON civicrm_activity.source_record_id = civicrm_mailing.id
SET civicrm_activity.activity_type_id = @newClientSMSValue
WHERE civicrm_activity.activity_type_id = @clientSMSValue;
-- CRM-10671 remove incomplete price set reports (inserted in 4.2 alpha 1)
SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
DELETE from civicrm_option_value
WHERE name = 'CRM_Report_Form_Price_Lineitem' AND
option_group_id = @option_group_id_report;
DELETE from civicrm_option_value
WHERE name = 'CRM_Report_Form_Price_Contributionbased' AND
option_group_id = @option_group_id_report;
DELETE from civicrm_option_value
WHERE name = 'CRM_Report_Form_Price_Lineitemparticipant' AND
option_group_id = @option_group_id_report;

View file

@ -0,0 +1,4 @@
-- CRM-10794
DELETE FROM civicrm_payment_processor_type WHERE name = 'ClickAndPledge';
DELETE FROM civicrm_payment_processor WHERE payment_processor_type = 'ClickAndPledge';

View file

@ -0,0 +1,21 @@
-- CRM-10810
SELECT @max_strict := max(id), @cnt_strict := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Strict' AND `is_default` = 1;
UPDATE `civicrm_dedupe_rule_group` SET `is_default` = 0 WHERE @cnt_strict > 1 AND id = @max_strict;
SELECT @max_fuzzy := max(id), @cnt_fuzzy := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Fuzzy' AND `is_default` = 1;
UPDATE `civicrm_dedupe_rule_group` SET `is_default` = 0 WHERE @cnt_fuzzy > 1 AND id = @max_fuzzy;
-- Insert line items for contribution for api/import
SELECT @fieldID := cpf.id, @fieldValueID := cpfv.id FROM civicrm_price_set cps
LEFT JOIN civicrm_price_field cpf ON cps.id = cpf.price_set_id
LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
WHERE cps.name = 'default_contribution_amount';
INSERT INTO civicrm_line_item ( entity_table, entity_id, price_field_id,label, qty, unit_price, line_total, participant_count, price_field_value_id )
SELECT 'civicrm_contribution', cc.id, @fieldID, 'Contribution Amount', 1, total_amount, total_amount , 0, @fieldValueID
FROM `civicrm_contribution` cc
LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
WHERE cli.entity_id IS NULL AND cc.contribution_page_id IS NULL AND cmp.contribution_id IS NULL AND cpp.contribution_id IS NULL
GROUP BY cc.id;

View file

@ -0,0 +1,49 @@
-- CRM-10969
SELECT @mailingsID := MAX(id) FROM civicrm_navigation WHERE name = 'Mailings' AND domain_id = {$domainID};
SELECT @navWeight := MAX(id) FROM civicrm_navigation WHERE name = 'New SMS' AND parent_id = @mailingsID;
UPDATE civicrm_navigation SET has_separator = NULL
WHERE name = 'New SMS' AND parent_id = @mailingsID AND has_separator = 1;
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/mailing/browse?reset=1&sms=1', '{ts escape="sql" skip="true"}Find Mass SMS{/ts}', 'Find Mass SMS', 'administer CiviCRM', NULL, @mailingsID, '1', 1, @navWeight+1 );
-- CRM-10980 and CRM-11014
SELECT @optionID := max(id) FROM civicrm_option_value WHERE name = 'BULK SMS';
{if $multilingual}
{foreach from=$locales item=locale}
UPDATE `civicrm_option_value` SET label_{$locale} = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description_{$locale} = '{ts escape="sql"}Mass SMS{/ts}' WHERE id = @optionID;
ALTER TABLE `civicrm_price_field_value` CHANGE name name VARCHAR(255) NULL DEFAULT NULL, CHANGE label_{$locale} label_{$locale} VARCHAR(255) NULL DEFAULT NULL;
{/foreach}
{else}
UPDATE `civicrm_option_value` SET label = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description = '{ts escape="sql"}Mass SMS{/ts}' WHERE name = 'BULK SMS';
ALTER TABLE `civicrm_price_field_value` CHANGE `name` `name` VARCHAR(255) NULL DEFAULT NULL, CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
{/if}
-- CRM-11014
ALTER TABLE `civicrm_line_item` CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
-- CRM-10986: Rename Batches UI elements to Bulk Data Entry
-- update reserved profile titles
{if $multilingual}
{foreach from=$locales item=locale}
UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
{/foreach}
{else}
UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
{/if}
-- update navigation menu items and fix typo in permission column
UPDATE `civicrm_navigation` SET label = '{ts escape="sql"}Bulk Data Entry{/ts}', name = 'Bulk Data Entry',
permission = 'access CiviMember, access CiviContribute'
WHERE url = 'civicrm/batch&reset=1';
-- CRM-11018
ALTER TABLE civicrm_discount DROP FOREIGN KEY FK_civicrm_discount_option_group_id;
ALTER TABLE `civicrm_discount`
ADD CONSTRAINT `FK_civicrm_discount_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_price_set` (`id`) ON DELETE CASCADE;
ALTER TABLE `civicrm_discount` CHANGE `option_group_id` `option_group_id` int(10) unsigned NOT NULL COMMENT 'FK to civicrm_price_set';

View file

@ -0,0 +1,10 @@
-- Placeholder which ensures that PHP upgrade tasks are executed
-- Get domain id
SELECT @domainID := min(id) FROM civicrm_domain;
-- CRM-11060
INSERT INTO `civicrm_job`
( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
VALUES
( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Send Scheduled SMS{/ts}', '{ts escape="sql" skip="true"}Sends out scheduled SMS{/ts}', 'civicrm_api3', 'job', 'process_sms', NULL, 0);

View file

@ -0,0 +1,2 @@
-- Placeholder which ensures that PHP upgrade tasks are executed

View file

@ -0,0 +1,15 @@
-- CRM-11354 Fix empty permissions for report instances
UPDATE civicrm_report_instance SET permission = 'access CiviReport'
WHERE report_id = 'survey/detail' and permission = '';
UPDATE civicrm_report_instance SET permission = 'access CiviMail'
WHERE report_id = 'mailing/detail' and permission = '';
UPDATE civicrm_report_instance SET permission = 'access CiviMember'
WHERE report_id = 'member/contributionDetail' and permission = '';
UPDATE civicrm_report_instance SET permission = 'access CiviGrant'
WHERE report_id = 'grant/statistics' and permission = '';
UPDATE civicrm_report_instance SET permission = 'access CiviReport'
WHERE permission = '0' OR permission = '' OR permission IS NULL;

View file

@ -0,0 +1,2 @@
-- Placeholder which ensures that PHP upgrade tasks are executed

View file

@ -0,0 +1,2 @@
-- Placeholder which ensures that PHP upgrade tasks are executed

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
{include file='../CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl'}
-- CRM-10326
DELETE FROM `civicrm_price_set_entity` WHERE entity_table = "civicrm_contribution" or entity_table = "civicrm_participant";
-- When deleting saved searches, null-out references from groups
ALTER TABLE civicrm_group ADD CONSTRAINT `FK_civicrm_group_saved_search_id`
FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`)
ON DELETE SET NULL;

View file

@ -0,0 +1,2 @@
{include file='../CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl'}

View file

@ -0,0 +1,37 @@
-- /*******************************************************
-- * CRM-10477 - Extensions updates
-- *******************************************************/
CREATE TABLE `civicrm_extension` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Local Extension ID',
`type` enum('payment', 'search', 'report', 'module') NOT NULL ,
`full_name` varchar(255) NOT NULL COMMENT 'Fully qualified extension name',
`name` varchar(255) COMMENT 'Short name',
`label` varchar(255) COMMENT 'Short, printable name',
`file` varchar(255) COMMENT 'Primary PHP file',
`schema_version` varchar(63) COMMENT 'Revision code of the database schema; the format is module-defined',
`is_active` tinyint DEFAULT 1 COMMENT 'Is this extension active?' ,
PRIMARY KEY ( `id` ) ,
UNIQUE INDEX `UI_extension_full_name`(
`full_name`
),
INDEX `UI_extension_name`(
`name`
)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- assuming first value of array $locales is always en_US
{if $multilingual}
INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
SELECT ov.label_{$locales.0}, ov.value, ov.name, ov.grouping, ov.description_{$locales.0}, ov.is_active
FROM civicrm_option_group og
INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
WHERE og.name = "system_extensions";
{else}
INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
SELECT ov.label, ov.value, ov.name, ov.grouping, ov.description, ov.is_active
FROM civicrm_option_group og
INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
WHERE og.name = "system_extensions";
{/if}
DELETE FROM civicrm_option_group WHERE name = "system_extensions";
-- Note: Deletion cascades to civicrm_option_value

View file

@ -0,0 +1 @@
-- Placeholder which ensures that PHP upgrade tasks are executed

View file

@ -0,0 +1,2 @@
{include file='../CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl'}

View file

@ -0,0 +1 @@
-- Placeholder which ensures that PHP upgrade tasks are executed

View file

@ -0,0 +1,23 @@
-- FIXME: the final release version is uncertain -- could 4.2.0 or 4.2.1; make sure this fixed before merging
-- CRM-10660
CREATE TABLE `civicrm_managed` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Surrogate Key',
`module` varchar(127) NOT NULL COMMENT 'Name of the module which declared this object',
`name` varchar(127) COMMENT 'Symbolic name used by the module to identify the object',
`entity_type` varchar(64) NOT NULL COMMENT 'API entity type',
`entity_id` int unsigned NOT NULL COMMENT 'Foreign key to the referenced item.',
PRIMARY KEY ( `id` )
, INDEX `UI_managed_module_name`(
`module`
, `name`
)
, INDEX `UI_managed_entity`(
`entity_type`
, `entity_id`
)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;

View file

@ -0,0 +1,2 @@
-- CRM-12290
UPDATE civicrm_currency SET symbol = 'N$' WHERE name = 'NAD';

View file

@ -0,0 +1,21 @@
-- CRM-12351
UPDATE civicrm_dedupe_rule_group SET title = name WHERE title IS NULL;
-- CRM-12373
SELECT @bounceTypeID := max(id) FROM civicrm_mailing_bounce_type WHERE name = 'Dns';
INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern)
VALUES
(@bounceTypeID, 'Host or domain name not found');
SELECT @bounceTypeID := max(id) FROM civicrm_mailing_bounce_type WHERE name = 'Host';
INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern)
VALUES
(@bounceTypeID, 'lost connection'),
(@bounceTypeID, 'conversation with [^ ]* timed out while');
SELECT @bounceTypeID := max(id) FROM civicrm_mailing_bounce_type WHERE name = 'Relay';
INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern)
VALUES
(@bounceTypeID, 'No route to host'),
(@bounceTypeID, 'Network is unreachable');

View file

@ -0,0 +1 @@
{* placeholder file for upgrade*}

View file

@ -0,0 +1,2 @@
-- CRM-12501
ALTER TABLE civicrm_financial_account CHANGE `tax_rate` `tax_rate` DECIMAL( 10, 8 ) NULL DEFAULT NULL COMMENT 'The percentage of the total_amount that is due for this tax.';

View file

@ -0,0 +1,109 @@
{* file to handle db changes in 4.3.4 during upgrade*}
-- CRM-12466
INSERT INTO
civicrm_option_group (name, {localize field='title'}title{/localize}, is_reserved, is_active)
VALUES
('contact_smart_group_display', {localize}'{ts escape="sql"}Contact Smart Group View Options{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_csgOpt := max(id) FROM civicrm_option_group WHERE name = 'contact_smart_group_display';
INSERT INTO
civicrm_option_value (option_group_id, {localize field='label'}label{/localize}, value, name, grouping, filter,
is_default, weight)
VALUES
(@option_group_id_csgOpt, {localize}'Show Smart Groups on Demand'{/localize}, 1, 'showondemand', NULL, 0, 0, 1),
(@option_group_id_csgOpt, {localize}'Always Show Smart Groups'{/localize}, 2, 'alwaysshow', NULL, 0, 0, 2),
(@option_group_id_csgOpt, {localize}'Hide Smart Groups'{/localize}, 3, 'hide' , NULL, 0, 0, 3);
INSERT INTO civicrm_setting
(domain_id, contact_id, is_domain, group_name, name, value)
VALUES
({$domainID}, NULL, 1, 'CiviCRM Preferences', 'contact_smart_group_display', '{serialize}1{/serialize}');
-- CRM-12665 remove options groups
DELETE cov, cog FROM civicrm_option_group cog
INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id
WHERE cog.name IN ('grant_program_status', 'allocation_algorithm');
-- CRM-12470
UPDATE civicrm_financial_account
SET is_default = 1
WHERE name IN ('Premiums', 'Banking Fees', 'Accounts Payable', 'Donation');
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
SELECT @option_group_id_fat := max(id) from civicrm_option_group where name = 'financial_account_type';
SELECT @domainContactId := contact_id from civicrm_domain where id = {$domainID};
-- for Accounts Receivable Account is
SELECT @option_value_rel_id_ar := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Accounts Receivable Account is';
SELECT @arAccount := id FROM civicrm_financial_account WHERE name = 'accounts receivable';
SELECT @arAccountEntity := financial_account_id FROM civicrm_entity_financial_account
WHERE account_relationship = @option_value_rel_id_ar AND entity_table = 'civicrm_financial_type' LIMIT 1;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_ar, IFNULL(@arAccount, @arAccountEntity)
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_ar AND ceft.entity_table = 'civicrm_financial_type'
WHERE ceft.entity_id IS NULL;
-- for income account is
SELECT @option_value_rel_id := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Income Account is';
SELECT @opval := value FROM civicrm_option_value WHERE name = 'Revenue' and option_group_id = @option_group_id_fat;
-- create FA if not exists with same name as financial type
INSERT INTO civicrm_financial_account (name, contact_id, financial_account_type_id, description, account_type_code, is_active)
SELECT cft.name, @domainContactId, @opval, cft.name as description, 'INC', 1
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id AND ceft.entity_table = 'civicrm_financial_type'
LEFT JOIN civicrm_financial_account ca ON ca.name = cft.name
WHERE ceft.entity_id IS NULL AND ca.id IS NULL;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id, ca.id
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id AND ceft.entity_table = 'civicrm_financial_type'
LEFT JOIN civicrm_financial_account ca ON ca.name = cft.name
WHERE ceft.entity_id IS NULL;
-- for cost of sales
SELECT @option_value_rel_id_cg := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Cost of Sales Account is';
SELECT @opCost := value FROM civicrm_option_value WHERE name = 'Cost of Sales' and option_group_id = @option_group_id_fat;
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opCost;
-- CRM-13231
INSERT IGNORE INTO civicrm_financial_account (id, name, contact_id, financial_account_type_id, description, account_type_code, accounting_code, is_active, is_default)
VALUES (@financialAccountId, 'Premiums', @domainContactId, @opCost, 'Account to record cost of premiums provided to payors', 'COGS', '5100', 1, 1);
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opCost;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_cg, @financialAccountId
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_cg AND ceft.entity_table = 'civicrm_financial_type'
WHERE ceft.entity_id IS NULL;
-- for Expense Account is
SELECT @option_value_rel_id_exp := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Expense Account is';
SELECT @opexp := value FROM civicrm_option_value WHERE name = 'Expenses' and option_group_id = @option_group_id_fat;
SET @financialAccountId := '';
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opexp;
-- CRM-13231
INSERT IGNORE INTO civicrm_financial_account (id, name, contact_id, financial_account_type_id, description, account_type_code, accounting_code, is_active, is_default)
VALUES (@financialAccountId, 'Banking Fees', @domainContactId, @opexp, 'Payment processor fees and manually recorded banking fees', 'EXP', '5200', 1, 1);
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opexp;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_exp, @financialAccountId
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_exp AND ceft.entity_table = 'civicrm_financial_type'
WHERE ceft.entity_id IS NULL;

View file

@ -0,0 +1,11 @@
{* file to handle db changes in 4.3.5 during upgrade*}
{include file='../CRM/Upgrade/4.3.5.msg_template/civicrm_msg_template.tpl'}
-- CRM-12799
DROP TABLE IF EXISTS civicrm_payment;
-- CRM-12929
INSERT INTO civicrm_setting
(domain_id, contact_id, is_domain, group_name, name, value)
VALUES
({$domainID}, NULL, 1, 'CiviCRM Preferences', 'allowPermDeleteFinancial', '{serialize}0{/serialize}');

View file

@ -0,0 +1,96 @@
{* file to handle db changes in 4.3.6 during upgrade *}
-- CRM-13060
UPDATE civicrm_price_set_entity cpse
LEFT JOIN civicrm_price_set cps ON cps.id = cpse.price_set_id
LEFT JOIN civicrm_price_field cpf ON cps.id = cpf.price_set_id
LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
LEFT JOIN civicrm_event ce ON cpse.entity_id = ce.id AND cpse.entity_table = 'civicrm_event'
LEFT JOIN civicrm_contribution_page ccg ON cpse.entity_id = ccg.id AND cpse.entity_table = 'civicrm_contribution_page'
SET cpfv.financial_type_id = CASE
WHEN ce.id IS NOT NULL
THEN ce.financial_type_id
WHEN ccg.id IS NOT NULL
THEN ccg.financial_type_id
END,
cps.financial_type_id = CASE
WHEN ce.id IS NOT NULL
THEN ce.financial_type_id
WHEN ccg.id IS NOT NULL
THEN ccg.financial_type_id
END
WHERE cps.is_quick_config = 1;
-- CRM-12844
-- DELETE bad data
DELETE cli FROM `civicrm_contribution` cc
LEFT JOIN civicrm_line_item cli ON cli.entity_id = cc.id
LEFT JOIN civicrm_financial_item cfi ON cfi.entity_id = cli.id AND cfi.entity_table = 'civicrm_line_item'
LEFT JOIN civicrm_price_field cpf ON cpf.id = cli.price_field_id
LEFT JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id
WHERE cc.contribution_recur_id IS NOT NULL
AND cli.entity_table = 'civicrm_contribution' AND cfi.id IS NULL
AND cps.is_quick_config = 1;
-- Set from_financial_account_id to null
UPDATE `civicrm_contribution` cc
LEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.entity_id = cc.id
LEFT JOIN civicrm_financial_trxn cft ON cft.id = ceft.financial_trxn_id
LEFT JOIN civicrm_entity_financial_trxn ceft1 ON ceft1.financial_trxn_id = ceft.financial_trxn_id
LEFT JOIN civicrm_financial_item cfi ON cfi.id = ceft1.entity_id
LEFT JOIN civicrm_entity_financial_account cefa ON cefa.entity_id = cft.payment_processor_id
SET cft.from_financial_account_id = NULL
WHERE ceft.entity_table = 'civicrm_contribution' AND cc.contribution_recur_id IS NOT NULL
AND ceft1.entity_table = 'civicrm_financial_item' AND cft.id IS NOT NULL AND cft.payment_instrument_id = 1 AND cfi.entity_table = 'civicrm_line_item' AND cft.from_financial_account_id IS NOT NULL
AND cefa.entity_table = 'civicrm_payment_processor' AND cefa.financial_account_id = cft.to_financial_account_id;
-- CRM-13096
DROP TABLE IF EXISTS civicrm_official_receipt;
-- CRM-13231
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
SELECT @option_group_id_fat := max(id) from civicrm_option_group where name = 'financial_account_type';
SELECT @opexp := value FROM civicrm_option_value WHERE name = 'Expenses' and option_group_id = @option_group_id_fat;
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opexp;
SELECT @domainContactId := contact_id from civicrm_domain where id = {$domainID};
SELECT @option_value_rel_id_exp := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Expense Account is';
INSERT IGNORE INTO civicrm_financial_account (id, name, contact_id, financial_account_type_id, description, account_type_code, accounting_code, is_active, is_default)
VALUES (@financialAccountId, 'Banking Fees', @domainContactId, @opexp, 'Payment processor fees and manually recorded banking fees', 'EXP', '5200', 1, 1);
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opexp;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_exp, @financialAccountId
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_exp AND ceft.entity_table = 'civicrm_financial_type'
WHERE ceft.entity_id IS NULL;
UPDATE civicrm_financial_trxn cft
INNER JOIN civicrm_entity_financial_trxn ceft ON ceft.financial_trxn_id = cft .id
INNER JOIN civicrm_entity_financial_trxn ceft1 ON ceft1.financial_trxn_id = cft .id
INNER JOIN civicrm_financial_item cfi ON cfi.id = ceft1.entity_id
INNER JOIN civicrm_contribution cc ON cc.id = ceft.entity_id
INNER JOIN civicrm_entity_financial_account cefa ON cefa.entity_id = cc.financial_type_id
SET cft.to_financial_account_id = cefa.financial_account_id
WHERE ceft.entity_table = 'civicrm_contribution' AND ceft1.entity_table = 'civicrm_financial_item' AND cfi.entity_table = 'civicrm_financial_trxn' AND cft.to_financial_account_id IS NULL AND cefa.entity_table = 'civicrm_financial_type' AND cefa.account_relationship = @option_value_rel_id_exp;
-- Add COGS account relationship
SELECT @option_value_rel_id_cg := value FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel AND name = 'Cost of Sales Account is';
SELECT @opCost := value FROM civicrm_option_value WHERE name = 'Cost of Sales' and option_group_id = @option_group_id_fat;
SET @financialAccountId := '';
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opCost;
-- CRM-13231
INSERT IGNORE INTO civicrm_financial_account (id, name, contact_id, financial_account_type_id, description, account_type_code, accounting_code, is_active, is_default)
VALUES (@financialAccountId, 'Premiums', @domainContactId, @opCost, 'Account to record cost of premiums provided to payors', 'COGS', '5100', 1, 1);
SELECT @financialAccountId := id FROM civicrm_financial_account WHERE is_default = 1 and financial_account_type_id = @opCost;
INSERT INTO civicrm_entity_financial_account(entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_cg, @financialAccountId
FROM civicrm_financial_type cft
LEFT JOIN civicrm_entity_financial_account ceft
ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_cg AND ceft.entity_table = 'civicrm_financial_type'
WHERE ceft.entity_id IS NULL;

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.3.7 during upgrade *}

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.3.8 during upgrade *}

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.3.9 during upgrade *}

View file

@ -0,0 +1,876 @@
{include file='../CRM/Upgrade/4.3.alpha1.msg_template/civicrm_msg_template.tpl'}
-- CRM-10999
ALTER TABLE `civicrm_premiums`
ADD COLUMN `premiums_nothankyou_position` int(10) unsigned DEFAULT '1';
-- CRM-11514 if contribution type name is null, assign it a name
UPDATE civicrm_contribution_type
SET name = CONCAT('Unknown_', id)
WHERE name IS NULL OR TRIM(name) = '';
-- CRM-8507
ALTER TABLE civicrm_custom_field
ADD UNIQUE INDEX `UI_name_custom_group_id` (`name`, `custom_group_id`);
--CRM-10473 Added Missing Provinces of Ningxia Autonomous Region of China
INSERT INTO `civicrm_state_province`(`country_id`, `abbreviation`, `name`) VALUES
(1045, 'YN', 'Yinchuan'),
(1045, 'SZ', 'Shizuishan'),
(1045, 'WZ', 'Wuzhong'),
(1045, 'GY', 'Guyuan'),
(1045, 'ZW', 'Zhongwei');
-- CRM-10553
ALTER TABLE civicrm_contact
ADD COLUMN `created_date` timestamp NULL DEFAULT NULL
COMMENT 'When was the contact was created.';
ALTER TABLE civicrm_contact
ADD COLUMN `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
COMMENT 'When was the contact (or closely related entity) was created or modified or deleted.';
-- CRM-10296
DELETE FROM civicrm_job WHERE `api_action` = 'process_membership_reminder_date';
ALTER TABLE civicrm_membership DROP COLUMN reminder_date;
ALTER TABLE civicrm_membership_log DROP COLUMN renewal_reminder_date;
ALTER TABLE civicrm_membership_type
DROP COLUMN renewal_reminder_day,
DROP FOREIGN KEY FK_civicrm_membership_type_renewal_msg_id,
DROP INDEX FK_civicrm_membership_type_renewal_msg_id,
DROP COLUMN renewal_msg_id,
DROP COLUMN autorenewal_msg_id;
-- CRM-10738
ALTER TABLE civicrm_msg_template
CHANGE msg_text msg_text LONGTEXT NULL COMMENT 'Text formatted message',
CHANGE msg_html msg_html LONGTEXT NULL COMMENT 'HTML formatted message';
-- CRM-10860
ALTER TABLE civicrm_contribution_page ADD COLUMN is_recur_installments tinyint(4) DEFAULT '0';
UPDATE civicrm_contribution_page SET is_recur_installments='1';
-- CRM-10863
SELECT @country_id := id from civicrm_country where name = 'Luxembourg' AND iso_code = 'LU';
INSERT IGNORE INTO `civicrm_state_province`(`country_id`, `abbreviation`, `name`) VALUES
(@country_id, 'L', 'Luxembourg');
-- CRM-10899 and CRM-10999
{if $multilingual}
{foreach from=$locales item=locale}
UPDATE civicrm_option_group SET title_{$locale} = '{ts escape="sql"}Currencies Enabled{/ts}' WHERE name = "currencies_enabled";
ALTER TABLE `civicrm_premiums`
ADD COLUMN premiums_nothankyou_label_{$locale} varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Label displayed for No Thank-you option in premiums block (e.g. No thank you)';
{/foreach}
{else}
UPDATE civicrm_option_group SET title = '{ts escape="sql"}Currencies Enabled{/ts}' WHERE name = "currencies_enabled";
{/if}
-- CRM-11047
ALTER TABLE civicrm_job DROP COLUMN api_prefix;
-- CRM-11068, CRM-10678, CRM-11759
ALTER TABLE civicrm_group
ADD refresh_date datetime default NULL COMMENT 'Date and time when we need to refresh the cache next.' AFTER `cache_date`,
ADD COLUMN `created_id` INT(10) unsigned DEFAULT NULL COMMENT 'FK to contact table, creator of the group.';
-- CRM-11759
ALTER TABLE civicrm_group
ADD CONSTRAINT `FK_civicrm_group_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL;
INSERT INTO `civicrm_job`
( domain_id, run_frequency, last_run, name, description, api_entity, api_action, parameters, is_active )
VALUES
( {$domainID}, 'Always' , NULL, '{ts escape="sql" skip="true"}Rebuild Smart Group Cache{/ts}', '{ts escape="sql" skip="true"}Rebuilds the smart group cache.{/ts}', 'job', 'group_rebuild', '{ts escape="sql" skip="true"}limit=Number optional-Limit the number of smart groups rebuild{/ts}', 0),
( {$domainID}, 'Daily' , NULL, '{ts escape="sql" skip="true"}Validate Email Address from Mailings.{/ts}', '{ts escape="sql" skip="true"}Updates the reset_date on an email address to indicate that there was a valid delivery to this email address.{/ts}', 'mailing', 'update_email_resetdate', '{ts escape="sql" skip="true"}minDays, maxDays=Consider mailings that have completed between minDays and maxDays{/ts}', 0);
-- CRM-11117
INSERT IGNORE INTO `civicrm_setting` (`group_name`, `name`, `value`, `domain_id`, `is_domain`) VALUES ('CiviCRM Preferences', 'activity_assignee_notification_ics', 's:1:"0";', {$domainID}, '1');
-- CRM-10885
ALTER TABLE civicrm_dedupe_rule_group
ADD used enum('Unsupervised','Supervised','General') COLLATE utf8_unicode_ci NOT NULL COMMENT 'Whether the rule should be used for cases where usage is Unsupervised, Supervised OR General(programatically)' AFTER threshold;
UPDATE civicrm_dedupe_rule_group
SET used = 'General' WHERE is_default = 0;
UPDATE civicrm_dedupe_rule_group
SET used = CASE level
WHEN 'Fuzzy' THEN 'Supervised'
WHEN 'Strict' THEN 'Unsupervised'
END
WHERE is_default = 1;
UPDATE civicrm_dedupe_rule_group
SET name = CONCAT_WS('', `contact_type`, `used`)
WHERE is_default = 1 OR is_reserved = 1;
UPDATE civicrm_dedupe_rule_group
SET title = 'Name and Email'
WHERE contact_type IN ('Organization', 'Household') AND used IN ('Unsupervised', 'Supervised');
UPDATE civicrm_dedupe_rule_group
SET title = CASE used
WHEN 'Supervised' THEN 'Name and Email (reserved)'
WHEN 'Unsupervised' THEN 'Email (reserved)'
WHEN 'General' THEN 'Name and Address (reserved)'
END
WHERE contact_type = 'Individual' AND is_reserved = 1;
ALTER TABLE civicrm_dedupe_rule_group DROP COLUMN level;
-- CRM-10771
ALTER TABLE civicrm_uf_field
ADD `is_multi_summary` tinyint(4) DEFAULT '0' COMMENT 'Include in multi-record listing?';
-- CRM-1115
-- note that country names are not translated in the DB
SELECT @region_id := max(id) from civicrm_worldregion where name = "Europe and Central Asia";
INSERT IGNORE INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Kosovo", "XK", @region_id, 0);
UPDATE civicrm_country SET name = 'Libya' WHERE name LIKE 'Libyan%';
UPDATE civicrm_country SET name = 'Congo, Republic of the' WHERE name = 'Congo';
-- CRM-10621 Add component report links to reports menu for upgrade
SELECT @reportlastID := MAX(id) FROM civicrm_navigation where name = 'Reports' AND domain_id = {$domainID};
SELECT @max_weight := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id = @reportlastID;
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=99&reset=1', '{ts escape="sql" skip="true"}Contact Reports{/ts}', 'Contact Reports', 'administer CiviCRM', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1) );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=2&reset=1', '{ts escape="sql" skip="true"}Contribution Reports{/ts}', 'Contribution Reports', 'access CiviContribute', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1) );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=6&reset=1', '{ts escape="sql" skip="true"}Pledge Reports{/ts}', 'Pledge Reports', 'access CiviPledge', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1) );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=1&reset=1', '{ts escape="sql" skip="true"}Event Reports{/ts}', 'Event Reports', 'access CiviEvent', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1));
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=4&reset=1', '{ts escape="sql" skip="true"}Mailing Reports{/ts}', 'Mailing Reports', 'access CiviMail', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1));
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=3&reset=1', '{ts escape="sql" skip="true"}Membership Reports{/ts}', 'Membership Reports', 'access CiviMember', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1));
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=9&reset=1', '{ts escape="sql" skip="true"}Campaign Reports{/ts}', 'Campaign Reports', 'interview campaign contacts,release campaign contacts,reserve campaign contacts,manage campaign,administer CiviCampaign,gotv campaign contacts', 'OR', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1));
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=7&reset=1', '{ts escape="sql" skip="true"}Case Reports{/ts}', 'Case Reports', 'access my cases and activities,access all cases and activities,administer CiviCase', 'OR', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1) );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/report/list&compid=5&reset=1', '{ts escape="sql" skip="true"}Grant Reports{/ts}', 'Grant Reports', 'access CiviGrant', '', @reportlastID, '1', 0, (SELECT @max_weight := @max_weight+1) );
-- CRM-11148 Multiple terms membership signup and renewal via price set
ALTER TABLE `civicrm_price_field_value` ADD COLUMN `membership_num_terms` INT(10) NULL DEFAULT NULL COMMENT 'Maximum number of related memberships.' AFTER `membership_type_id`;
-- CRM-11070
SELECT @option_group_id_tuf := max(id) from civicrm_option_group where name = 'tag_used_for';
SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_tuf;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
VALUES
(@option_group_id_tuf, {localize}'Attachments'{/localize}, 'civicrm_file', 'Attachments', NULL, 0, 0, @weight = @weight + 1);
ALTER TABLE civicrm_extension MODIFY COLUMN type ENUM( 'payment', 'search', 'report', 'module','sms') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;
-- CRM-9914
SELECT @option_group_id_sms_provider_name := max(id) from civicrm_option_group where name = 'sms_provider_name';
DELETE FROM civicrm_option_value WHERE option_group_id = @option_group_id_sms_provider_name AND name = 'Clickatell';
-- CRM-11292
ALTER TABLE `civicrm_phone`
ADD `phone_numeric` varchar(32)
COMMENT 'Phone number stripped of all whitespace, letters, and punctuation.'
AFTER `phone_ext`,
ADD INDEX phone_numeric_index(`phone_numeric`);
-- civiaccounts upgrade
-- ADD fields w.r.t 10.6 mwb
ALTER TABLE `civicrm_financial_account`
CHANGE `account_type_id` financial_account_type_id int(10) unsigned NOT NULL DEFAULT '3' COMMENT 'Version identifier of financial_type',
ADD `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Financial Type Description.',
ADD `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent ID in account hierarchy',
ADD `is_header_account` tinyint(4) DEFAULT NULL COMMENT 'Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?',
ADD `accounting_code` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Optional value for mapping monies owed and received to accounting system codes.',
ADD `account_type_code` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).',
ADD `is_deductible` tinyint(4) DEFAULT '1' COMMENT 'Is this account tax-deductible?',
ADD `is_tax` tinyint(4) DEFAULT '0' COMMENT 'Is this account for taxes?',
ADD `tax_rate` decimal(9,8) DEFAULT '0.00' COMMENT 'The percentage of the total_amount that is due for this tax.',
ADD `is_reserved` tinyint(4) DEFAULT NULL COMMENT 'Is this a predefined system object?',
ADD `is_active` tinyint(4) DEFAULT NULL COMMENT 'Is this property active?',
ADD `is_default` tinyint(4) DEFAULT NULL COMMENT 'Is this account the default one (or default tax one) for its financial_account_type?',
ADD CONSTRAINT `UI_name` UNIQUE INDEX (`name`),
ADD CONSTRAINT `FK_civicrm_financial_account_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_financial_account`(id);
-- CRM-8425
-- Rename table civicrm_contribution_type to civicrm_financial_type
RENAME TABLE `civicrm_contribution_type` TO `civicrm_financial_type`;
ALTER TABLE `civicrm_financial_type`
CHANGE `name` `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Financial Type Name.',
ADD CONSTRAINT `UI_id` UNIQUE INDEX(id),
DROP INDEX UI_name;
CREATE TABLE IF NOT EXISTS `civicrm_entity_financial_account` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`entity_table` varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Links to an entity_table like civicrm_financial_type',
`entity_id` int(10) unsigned NOT NULL COMMENT 'Links to an id in the entity_table, such as vid in civicrm_financial_type',
`account_relationship` int(10) unsigned NOT NULL COMMENT 'FK to a new civicrm_option_value (account_relationship)',
`financial_account_id` int(10) unsigned NOT NULL COMMENT 'FK to the financial_account_id',
PRIMARY KEY (`id`),
KEY `FK_civicrm_entity_financial_account_financial_account_id` (`financial_account_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- Constraints for table `civicrm_entity_financial_account`
ALTER TABLE `civicrm_entity_financial_account`
ADD CONSTRAINT `FK_civicrm_entity_financial_account_financial_account_id` FOREIGN KEY (`financial_account_id`) REFERENCES `civicrm_financial_account` (`id`);
-- CRM-9730 Table structure for table `civicrm_financial_item`
--
CREATE TABLE IF NOT EXISTS `civicrm_financial_item` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and time the item was created',
`transaction_date` datetime NOT NULL COMMENT 'Date and time of the source transaction',
`contact_id` int(10) unsigned NOT NULL COMMENT 'FK to Contact ID of contact the item is from',
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Human readable description of this item, to ease display without lookup of source item.',
`amount` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT 'Total amount of this item',
`currency` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Currency for the amount',
`financial_account_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to civicrm_financial_account',
`status_id` int(10) unsigned DEFAULT NULL COMMENT 'Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)',
`entity_table` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The table providing the source of this item such as civicrm_line_item',
`entity_id` int(10) unsigned DEFAULT NULL COMMENT 'The specific source item that is responsible for the creation of this financial_item',
PRIMARY KEY (`id`),
UNIQUE KEY `UI_id` (`id`),
KEY `IX_created_date` (`created_date`),
KEY `IX_transaction_date` (`transaction_date`),
KEY `IX_entity` (`entity_table`,`entity_id`),
KEY `FK_civicrm_financial_item_contact_id` (`contact_id`),
KEY `FK_civicrm_financial_item_financial_account_id` (`financial_account_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `civicrm_batch`
ADD `payment_instrument_id` int(10) unsigned DEFAULT NULL COMMENT 'fk to Payment Instrument options in civicrm_option_values',
ADD `exported_date` datetime DEFAULT NULL;
ALTER TABLE `civicrm_financial_item`
ADD CONSTRAINT `FK_civicrm_financial_item_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`),
ADD CONSTRAINT `FK_civicrm_financial_item_financial_account_id` FOREIGN KEY (`financial_account_id`) REFERENCES `civicrm_financial_account` (`id`);
ALTER TABLE `civicrm_entity_financial_trxn`
DROP currency;
-- CRM-12312
UPDATE civicrm_event SET contribution_type_id = NULL WHERE contribution_type_id = 0;
-- CRM-9189 and CRM-8425 change fk's to financial_account.id in our branch that will need to be changed to an fk to financial_type.id
ALTER TABLE `civicrm_pledge`
DROP FOREIGN KEY FK_civicrm_pledge_contribution_type_id,
DROP INDEX FK_civicrm_pledge_contribution_type_id;
ALTER TABLE `civicrm_pledge`
CHANGE `contribution_type_id` `financial_type_id` int unsigned COMMENT 'FK to Financial Type';
ALTER TABLE `civicrm_pledge`
ADD CONSTRAINT FK_civicrm_pledge_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
ALTER TABLE `civicrm_membership_type`
DROP FOREIGN KEY FK_civicrm_membership_type_contribution_type_id,
DROP INDEX FK_civicrm_membership_type_contribution_type_id;
ALTER TABLE `civicrm_membership_type`
CHANGE `contribution_type_id` `financial_type_id` int unsigned NOT NULL COMMENT 'If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id';
ALTER TABLE `civicrm_membership_type`
ADD CONSTRAINT FK_civicrm_membership_type_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
ALTER TABLE `civicrm_price_set`
DROP FOREIGN KEY FK_civicrm_price_set_contribution_type_id,
DROP INDEX FK_civicrm_price_set_contribution_type_id;
ALTER TABLE `civicrm_price_set`
CHANGE `contribution_type_id` `financial_type_id` int unsigned COMMENT 'If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id';
ALTER TABLE `civicrm_price_set`
ADD CONSTRAINT FK_civicrm_price_set_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
ALTER TABLE `civicrm_event`
CHANGE `contribution_type_id` `financial_type_id` int unsigned COMMENT 'Financial type assigned to paid event registrations for this event. Required if is_monetary is true.';
ALTER TABLE `civicrm_contribution`
DROP FOREIGN KEY FK_civicrm_contribution_contribution_type_id,
DROP INDEX FK_civicrm_contribution_contribution_type_id;
ALTER TABLE `civicrm_contribution`
CHANGE `contribution_type_id` `financial_type_id` int unsigned COMMENT 'FK to Financial Type for (total_amount - non_deductible_amount).';
ALTER TABLE `civicrm_contribution`
ADD CONSTRAINT FK_civicrm_contribution_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
ALTER TABLE `civicrm_contribution_page`
DROP FOREIGN KEY FK_civicrm_contribution_page_contribution_type_id,
DROP INDEX FK_civicrm_contribution_page_contribution_type_id;
ALTER TABLE `civicrm_contribution_page`
CHANGE `contribution_type_id` `financial_type_id` int unsigned DEFAULT NULL COMMENT 'default financial type assigned to contributions submitted via this page, e.g. Contribution, Campaign Contribution',
ADD `is_partial_payment` tinyint(4) DEFAULT '0' COMMENT 'is partial payment enabled for this event',
ADD `min_initial_amount` decimal(20,2) DEFAULT NULL COMMENT 'Minimum initial amount for partial payment';
{if $multilingual}
{foreach from=$locales item=loc}
ALTER TABLE `civicrm_contribution_page`
ADD `initial_amount_label_{$loc}` varchar(255) COLLATE utf8_unicode_ci COMMENT 'Initial amount label for partial payment',
ADD `initial_amount_help_text_{$loc}` text COLLATE utf8_unicode_ci COMMENT 'Initial amount help text for partial payment';
{/foreach}
{else}
ALTER TABLE `civicrm_contribution_page`
ADD `initial_amount_label` varchar(255) COLLATE utf8_unicode_ci COMMENT 'Initial amount label for partial payment',
ADD `initial_amount_help_text` text COLLATE utf8_unicode_ci COMMENT 'Initial amount help text for partial payment';
{/if}
ALTER TABLE `civicrm_contribution_page`
ADD CONSTRAINT FK_civicrm_contribution_page_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
ALTER TABLE `civicrm_contribution_recur`
CHANGE `contribution_type_id` `financial_type_id` int unsigned COMMENT 'FK to Financial Type';
ALTER TABLE `civicrm_contribution_recur`
ADD CONSTRAINT FK_civicrm_contribution_recur_financial_type_id FOREIGN KEY (`financial_type_id`) REFERENCES civicrm_financial_type (id);
-- CRM-9083
ALTER TABLE `civicrm_financial_trxn` CHANGE `to_account_id` `to_financial_account_id` int unsigned COMMENT 'FK to financial_financial_account table.',
CHANGE `from_account_id` `from_financial_account_id` int unsigned COMMENT 'FK to financial_account table.',
ADD `status_id` int(10) unsigned DEFAULT NULL,
CHANGE `trxn_id` trxn_id varchar(255) COMMENT 'unique processor transaction id, bank id + trans id,... depending on payment_method',
CHANGE `trxn_date` trxn_date datetime DEFAULT NULL,
ADD `payment_instrument_id` int unsigned DEFAULT NULL COMMENT 'FK to payment_instrument option group values',
ADD `check_number` VARCHAR( 255 ) NULL DEFAULT NULL,
ADD INDEX `UI_ftrxn_check_number` (`check_number`),
ADD INDEX `UI_ftrxn_payment_instrument_id` (`payment_instrument_id`);
ALTER TABLE `civicrm_financial_trxn`
ADD CONSTRAINT FK_civicrm_financial_trxn_to_financial_account_id FOREIGN KEY (`to_financial_account_id`) REFERENCES civicrm_financial_account (id),
ADD CONSTRAINT FK_civicrm_financial_trxn_from_financial_account_id FOREIGN KEY (`from_financial_account_id`) REFERENCES civicrm_financial_account (id);
ALTER TABLE `civicrm_financial_trxn` ADD `payment_processor_id` int unsigned COMMENT 'Payment Processor for this contribution Page';
-- Fill in the payment_processor_id based on a lookup using the payment_processor field
UPDATE `civicrm_payment_processor` cppt, `civicrm_financial_trxn` cft
SET cft.`payment_processor_id` = cppt.`id`
WHERE cft.`payment_processor` = cppt.`payment_processor_type` and `is_test` = 0;
-- remove payment_processor field
ALTER TABLE `civicrm_financial_trxn` DROP `payment_processor`;
ALTER TABLE `civicrm_financial_trxn`
ADD CONSTRAINT `FK_civicrm_financial_trxn_payment_processor_id` FOREIGN KEY (`payment_processor_id`) REFERENCES `civicrm_payment_processor` (`id`) ON DELETE SET NULL;
-- Drop index for civicrm_financial_trxn.trxn_id and set default to null
ALTER TABLE `civicrm_financial_trxn` CHANGE `trxn_id` `trxn_id` varchar( 255 ) DEFAULT NULL ;
ALTER TABLE `civicrm_financial_trxn` DROP INDEX UI_ft_trxn_id;
-- remove trxn_type field
ALTER TABLE `civicrm_financial_trxn` DROP `trxn_type`;
-- CRM-9731
ALTER TABLE `civicrm_payment_processor` ADD `payment_processor_type_id` int(10) unsigned NULL AFTER `description`,
ADD CONSTRAINT `FK_civicrm_payment_processor_payment_processor_type_id` FOREIGN KEY (`payment_processor_type_id`) REFERENCES `civicrm_payment_processor_type` (`id`);
UPDATE `civicrm_payment_processor` , `civicrm_payment_processor_type`
SET payment_processor_type_id = `civicrm_payment_processor_type`.id
WHERE payment_processor_type = `civicrm_payment_processor_type`.name;
ALTER TABLE `civicrm_payment_processor` DROP `payment_processor_type`;
-- CRM-9730
ALTER TABLE `civicrm_price_field_value` ADD `deductible_amount` DECIMAL( 20, 2 ) NOT NULL DEFAULT '0.00' COMMENT 'Tax-deductible portion of the amount';
ALTER TABLE `civicrm_line_item` ADD `deductible_amount` DECIMAL( 20, 2 ) NOT NULL DEFAULT '0.00' COMMENT 'Tax-deductible portion of the amount';
ALTER TABLE `civicrm_price_field_value` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_price_field_value_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
ALTER TABLE `civicrm_line_item` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_line_item_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
ALTER TABLE `civicrm_grant` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_grant_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
ALTER TABLE `civicrm_product` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_product_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
ALTER TABLE `civicrm_premiums_product` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_premiums_product_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
ALTER TABLE `civicrm_contribution_product` ADD
`financial_type_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Financial Type.',
ADD CONSTRAINT `FK_civicrm_contribution_product_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`);
-- CRM-11122
ALTER TABLE `civicrm_discount`
DROP FOREIGN KEY FK_civicrm_discount_option_group_id,
DROP INDEX FK_civicrm_discount_option_group_id;
ALTER TABLE `civicrm_discount` CHANGE `option_group_id` `price_set_id` INT( 10 ) UNSIGNED NOT NULL COMMENT 'FK to civicrm_price_set';
ALTER TABLE `civicrm_discount`
ADD CONSTRAINT `FK_civicrm_discount_price_set_id` FOREIGN KEY (`price_set_id`) REFERENCES `civicrm_price_set` (`id`) ON DELETE CASCADE;
-- CRM-8425
UPDATE civicrm_navigation SET `label` = 'Financial Types', `name` = 'Financial Types', `url` = 'civicrm/admin/financial/financialType?reset=1' WHERE `name` = 'Contribution Types';
-- CRM-9199
-- Insert menu item at Administer > CiviContribute, below the section break below Premiums (Thank-you Gifts), just below Financial Account.
SELECT @parent_id := id from `civicrm_navigation` where name = 'CiviContribute' AND domain_id = {$domainID};
SELECT @add_weight_id := weight from `civicrm_navigation` where `name` = 'Financial Types' and `parent_id` = @parent_id;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+1
WHERE `parent_id` = @parent_id
AND `weight` > @add_weight_id;
INSERT INTO `civicrm_navigation`
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/admin/financial/financialAccount&reset=1', '{ts escape="sql" skip="true"}Financial Account{/ts}', 'Financial Account', 'access CiviContribute,administer CiviCRM', 'AND', @parent_id, '1', NULL, @add_weight_id + 1 );
-- CRM-10944
SELECT @contributionlastID := max(id) from civicrm_navigation where name = 'Contributions' AND domain_id = {$domainID};
SELECT @pledgeWeight := weight from civicrm_navigation where name = 'Pledges' and parent_id = @contributionlastID;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+1
WHERE `parent_id` = @contributionlastID
AND `weight` > @pledgeWeight;
INSERT INTO civicrm_navigation
(domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight)
VALUES
({$domainID}, NULL, '{ts escape="sql" skip="true"}Accounting Batches{/ts}', 'Accounting Batches', 'access CiviContribute', '', @contributionlastID, '1', 1, @pledgeWeight+1);
SET @financialTransactionID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
(domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
({$domainID}, 'civicrm/financial/batch&reset=1&action=add', '{ts escape="sql" skip="true"}New Batch{/ts}', 'New Batch', 'access CiviContribute', 'AND', @financialTransactionID, '1', NULL, 1),
({$domainID}, 'civicrm/financial/financialbatches?reset=1&batchStatus=1', '{ts escape="sql" skip="true"}Open Batches{/ts}', 'Open Batches', 'access CiviContribute', 'AND', @financialTransactionID, '1', NULL, 2),
({$domainID}, 'civicrm/financial/financialbatches?reset=1&batchStatus=2', '{ts escape="sql" skip="true"}Closed Batches{/ts}', 'Closed Batches', 'access CiviContribute', 'AND', @financialTransactionID, '1', NULL, 3),
({$domainID}, 'civicrm/financial/financialbatches?reset=1&batchStatus=5', '{ts escape="sql" skip="true"}Exported Batches{/ts}', 'Exported Batches', 'access CiviContribute', 'AND', @financialTransactionID, '1', NULL, 4);
-- Insert an entry for financial_account_type in civicrm_option_group and for the the following financial account types in civicrm_option_value as per CRM-8425
INSERT INTO
`civicrm_option_group` (`name`, {localize field='title'}title{/localize}, `is_reserved`, `is_active`)
VALUES
('financial_account_type', {localize}'{ts escape="sql"}Financial Account Type{/ts}'{/localize}, 1, 1),
('account_relationship', {localize}'{ts escape="sql"}Account Relationship{/ts}'{/localize}, 1, 1),
('financial_item_status', {localize}'{ts escape="sql"}Financial Item Status{/ts}'{/localize}, 1, 1),
('batch_mode', {localize}'{ts escape="sql"}Batch Mode{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_fat := max(id) from civicrm_option_group where name = 'financial_account_type';
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
SELECT @option_group_id_financial_item_status := max(id) from civicrm_option_group where name = 'financial_item_status';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_fat, {localize}'{ts escape="sql"}Asset{/ts}'{/localize}, 1, 'Asset', NULL, 0, 0, 1, {localize}'Things you own'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_fat, {localize}'{ts escape="sql"}Liability{/ts}'{/localize}, 2, 'Liability', NULL, 0, 0, 2, {localize}'Things you own, like a grant still to be disbursed'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_fat, {localize}'{ts escape="sql"}Revenue{/ts}'{/localize}, 3, 'Revenue', NULL, 0, 1, 3, {localize}'Income from contributions and sales of tickets and memberships'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_fat, {localize}'{ts escape="sql"}Cost of Sales{/ts}'{/localize}, 4, 'Cost of Sales', NULL, 0, 0, 4, {localize}'Costs incurred to get revenue, e.g. premiums for donations, dinner for a fundraising dinner ticket'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_fat, {localize}'{ts escape="sql"}Expenses{/ts}'{/localize}, 5, 'Expenses', NULL, 0, 0, 5, {localize}'Things that are paid for that are consumable, e.g. grants disbursed'{/localize}, 0, 1, 1, 2, NULL),
-- Financial account relationship
(@option_group_id_arel, {localize}'{ts escape="sql"}Income Account is{/ts}'{/localize}, 1, 'Income Account is', NULL, 0, 1, 1, {localize}'Income Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Credit/Contra Account is{/ts}'{/localize}, 2, 'Credit/Contra Account is', NULL, 0, 0, 2, {localize}'Credit/Contra Account is'{/localize}, 0, 1, 0, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Accounts Receivable Account is{/ts}'{/localize}, 3, 'Accounts Receivable Account is', NULL, 0, 0, 3, {localize}'Accounts Receivable Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Credit Liability Account is{/ts}'{/localize}, 4, 'Credit Liability Account is', NULL, 0, 0, 4, {localize}'Credit Liability Account is'{/localize}, 0, 1, 0, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Expense Account is{/ts}'{/localize}, 5, 'Expense Account is', NULL, 0, 0, 5, {localize}'Expense Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Asset Account is{/ts}'{/localize}, 6, 'Asset Account is', NULL, 0, 0, 6, {localize}'Asset Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Cost of Sales Account is{/ts}'{/localize}, 7, 'Cost of Sales Account is', NULL, 0, 0, 7, {localize}'Cost of Sales Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Premiums Inventory Account is{/ts}'{/localize}, 8, 'Premiums Inventory Account is', NULL, 0, 0, 8, {localize}'Premiums Inventory Account is'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_arel, {localize}'{ts escape="sql"}Discounts Account is{/ts}'{/localize}, 9, 'Discounts Account is', NULL, 0, 0, 9, {localize}'Discounts Account is'{/localize}, 0, 1, 1, 2, NULL),
-- Financial Item Status
(@option_group_id_financial_item_status, {localize}'{ts escape="sql"}Paid{/ts}'{/localize}, 1, 'Paid', NULL, 0, 0, 1, {localize}'Paid'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_financial_item_status, {localize}'{ts escape="sql"}Partially paid{/ts}'{/localize}, 2, 'Partially paid', NULL, 0, 0, 2, {localize}'Partially paid'{/localize}, 0, 1, 1, 2, NULL),
(@option_group_id_financial_item_status, {localize}'{ts escape="sql"}Unpaid{/ts}'{/localize}, 3, 'Unpaid', NULL, 0, 0, 1, {localize}'Unpaid'{/localize}, 0, 1, 1, 2, NULL);
-- Data migration from civicrm_contibution_type to civicrm_financial_account, civicrm_financial_type, civicrm_entity_financial_account
SELECT @opval := value FROM civicrm_option_value WHERE name = 'Revenue' and option_group_id = @option_group_id_fat;
SELECT @domainContactId := contact_id from civicrm_domain where id = {$domainID};
INSERT INTO `civicrm_financial_account`
(`id`, `name`, `description`, `is_deductible`, `is_reserved`, `is_active`, `financial_account_type_id`, `contact_id`, accounting_code)
SELECT id, name, CONCAT('Default account for ', name), is_deductible, is_reserved, is_active, @opval, @domainContactId, accounting_code
FROM `civicrm_financial_type`;
-- CRM-9306 and CRM-11657
UPDATE `civicrm_financial_account` SET `is_default` = 0, `account_type_code` = 'INC';
SELECT @option_value_rel_id := value FROM `civicrm_option_value` WHERE `option_group_id` = @option_group_id_arel AND `name` = 'Income Account is';
SELECT @opexp := value FROM civicrm_option_value WHERE name = 'Expenses' and option_group_id = @option_group_id_fat;
SELECT @opAsset := value FROM civicrm_option_value WHERE name = 'Asset' and option_group_id = @option_group_id_fat;
SELECT @opLiability := value FROM civicrm_option_value WHERE name = 'Liability' and option_group_id = @option_group_id_fat;
SELECT @opCost := value FROM civicrm_option_value WHERE name = 'Cost of Sales' and option_group_id = @option_group_id_fat;
-- CRM-11522 drop accounting_code after coping its values into financial_account
ALTER TABLE civicrm_financial_type DROP accounting_code;
INSERT INTO
`civicrm_financial_account` (`name`, `contact_id`, `financial_account_type_id`, `description`, `accounting_code`, `account_type_code`, `is_reserved`, `is_active`, `is_deductible`, `is_default`)
VALUES
('Banking Fees' , @domainContactId, @opexp, 'Payment processor fees and manually recorded banking fees', '5200', 'EXP', 0, 1, 0, 0),
('Deposit Bank Account' , @domainContactId, @opAsset, 'All manually recorded cash and cheques go to this account', '1100', 'BANK', 0, 1, 0, 1),
('Accounts Receivable' , @domainContactId, @opAsset, 'Amounts to be received later (eg pay later event revenues)', '1200', 'AR', 0, 1, 0, 0),
('Accounts Payable' , @domainContactId, @opLiability, 'Amounts to be paid out such as grants and refunds', '2200', 'AP', 0, 1, 0, 0),
('Premiums' , @domainContactId, @opCost, 'Account to record cost of premiums provided to payors', '5100', 'COGS', 0, 1, 0, 0),
('Premiums Inventory' , @domainContactId, @opAsset, 'Account representing value of premiums inventory', '1375', 'OCASSET', 0, 1, 0, 0),
('Discounts' , @domainContactId, @opval, 'Contra-revenue account for amounts discounted from sales', '4900', 'INC', 0, 1, 0, 0),
('Payment Processor Account', @domainContactId, @opAsset, 'Account to record payments into a payment processor merchant account', '1150', 'BANK', 0, 1, 0, 0);
-- CRM-10926
SELECT @option_value_rel_id_exp := value FROM `civicrm_option_value` WHERE `option_group_id` = @option_group_id_arel AND `name` = 'Expense Account is';
SELECT @option_value_rel_id_ar := value FROM `civicrm_option_value` WHERE `option_group_id` = @option_group_id_arel AND `name` = 'Accounts Receivable Account is';
SELECT @option_value_rel_id_as := value FROM `civicrm_option_value` WHERE `option_group_id` = @option_group_id_arel AND `name` = 'Asset Account is';
SELECT @financial_account_id_bf := max(id) FROM `civicrm_financial_account` WHERE `name` = 'Banking Fees';
SELECT @financial_account_id_ap := max(id) FROM `civicrm_financial_account` WHERE `name` = 'Accounts Receivable';
INSERT INTO `civicrm_entity_financial_account`
( entity_table, entity_id, account_relationship, financial_account_id )
SELECT 'civicrm_financial_type', ft.id, @option_value_rel_id, fa.id
FROM `civicrm_financial_type` as ft LEFT JOIN `civicrm_financial_account` as fa ON ft.id = fa.id;
-- Banking Fees
INSERT INTO `civicrm_entity_financial_account`
( entity_table, entity_id, account_relationship, financial_account_id )
SELECT 'civicrm_financial_type', ft.id, @option_value_rel_id_exp, @financial_account_id_bf
FROM `civicrm_financial_type` as ft;
-- Accounts Receivable
INSERT INTO `civicrm_entity_financial_account`
( entity_table, entity_id, account_relationship, financial_account_id )
SELECT 'civicrm_financial_type', ft.id, @option_value_rel_id_ar, @financial_account_id_ap
FROM `civicrm_financial_type` as ft;
-- CRM-11516
SELECT @financial_account_id_ar := max(id) FROM `civicrm_financial_account` WHERE `name` = 'Deposit Bank Account';
SELECT @financial_account_id_pp := max(id) FROM `civicrm_financial_account` WHERE `name` = 'Payment Processor Account';
INSERT INTO civicrm_entity_financial_account (entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_option_value', cov.id, @option_value_rel_id_as, @financial_account_id_ar FROM `civicrm_option_group` cog
LEFT JOIN civicrm_option_value cov ON cog.id = cov.option_group_id
WHERE cog.name = 'payment_instrument' AND cov.name NOT IN ('Credit Card', 'Debit Card');
INSERT INTO civicrm_entity_financial_account (entity_table, entity_id, account_relationship, financial_account_id)
SELECT 'civicrm_option_value', cov.id, @option_value_rel_id_as, @financial_account_id_pp FROM `civicrm_option_group` cog
LEFT JOIN civicrm_option_value cov ON cog.id = cov.option_group_id
WHERE cog.name = 'payment_instrument' AND cov.name IN ('Credit Card', 'Debit Card');
-- CRM-11515
SELECT @financial_account_id_ppa := max(id) FROM `civicrm_financial_account` WHERE `name` = 'Payment Processor Account';
INSERT INTO civicrm_entity_financial_account (`entity_table`, `entity_id`, `account_relationship`, `financial_account_id`)
SELECT 'civicrm_payment_processor', id, @option_value_rel_id_as, @financial_account_id_ppa FROM `civicrm_payment_processor`;
-- CRM-9923 and CRM-11037
SELECT @option_group_id_batch_status := max(id) from civicrm_option_group where name = 'batch_status';
SELECT @weight := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
VALUES
(@option_group_id_batch_status, {localize}'Data Entry'{/localize}, @weight + 1, 'Data Entry', NULL, 0, 0, @weight + 1),
(@option_group_id_batch_status, {localize}'Reopened'{/localize}, @weight + 2, 'Reopened', NULL, 0, 0, @weight + 2),
(@option_group_id_batch_status, {localize}'Exported'{/localize}, @weight + 3, 'Exported' , NULL, 0, 0, @weight + 3);
-- Insert Batch Modes.
SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
VALUES
(@option_group_id_batch_modes, {localize}'Manual Batch'{/localize}, 1, 'Manual Batch', NULL, 0, 0, 1),
(@option_group_id_batch_modes, {localize}'Automatic Batch'{/localize}, 2, 'Automatic Batch' , NULL, 0, 0, 2);
-- End of civiaccounts upgrade
-- CRM-10933
ALTER TABLE `civicrm_report_instance`
ADD COLUMN `drilldown_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to instance ID drilldown to',
ADD CONSTRAINT `FK_civicrm_report_instance_drilldown_id` FOREIGN KEY (`drilldown_id`) REFERENCES `civicrm_report_instance` (`id`) ON DELETE SET NULL;
-- CRM-10012
ALTER TABLE `civicrm_membership_type`
ADD COLUMN `max_related` INT(10) unsigned DEFAULT NULL COMMENT 'Maximum number of related memberships.' AFTER `relationship_direction`;
ALTER TABLE `civicrm_membership`
ADD COLUMN `max_related` INT(10) unsigned DEFAULT NULL COMMENT 'Maximum number of related memberships (membership_type override).' AFTER `owner_membership_id`;
ALTER TABLE `civicrm_membership_log`
ADD COLUMN `max_related` INT(10) unsigned DEFAULT NULL COMMENT 'Maximum number of related memberships.' AFTER `membership_type_id`;
-- CRM-11358
DELETE FROM civicrm_dashboard_contact WHERE contact_id NOT IN (SELECT id FROM civicrm_contact);
INSERT INTO `civicrm_dashboard`
(`domain_id`, {localize field='label'}`label`{/localize}, `url`, `permission`, `permission_operator`, `column_no`, `is_minimized`, `is_active`, `weight`, `fullscreen_url`, `is_fullscreen`, `is_reserved`)
SELECT id, {localize}'{ts escape="sql"}CiviCRM News{/ts}'{/localize}, 'civicrm/dashlet/blog&reset=1&snippet=5', 'access CiviCRM', NULL, 0, 0, 1, 0, 'civicrm/dashlet/blog&reset=1&snippet=5&context=dashletFullscreen', 1, 1
FROM `civicrm_domain`;
INSERT INTO `civicrm_dashboard_contact` (dashboard_id, contact_id, column_no, is_active)
SELECT (SELECT MAX(id) FROM `civicrm_dashboard`), contact_id, 1, IF (SUM(is_active) > 0, 0, 1)
FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id;
-- CRM-11387
ALTER TABLE `civicrm_event`
ADD `is_partial_payment` tinyint(4) DEFAULT '0' COMMENT 'is partial payment enabled for this event',
ADD `min_initial_amount` decimal(20,2) DEFAULT NULL COMMENT 'Minimum initial amount for partial payment';
{if $multilingual}
{foreach from=$locales item=loc}
ALTER TABLE `civicrm_event`
ADD `initial_amount_label_{$loc}` varchar(255) COLLATE utf8_unicode_ci COMMENT 'Initial amount label for partial payment',
ADD `initial_amount_help_text_{$loc}` text COLLATE utf8_unicode_ci COMMENT 'Initial amount help text for partial payment';
{/foreach}
{else}
ALTER TABLE `civicrm_event`
ADD `initial_amount_label` varchar(255) COLLATE utf8_unicode_ci COMMENT 'Initial amount label for partial payment',
ADD `initial_amount_help_text` text COLLATE utf8_unicode_ci COMMENT 'Initial amount help text for partial payment';
{/if}
-- CRM-11347
UPDATE `civicrm_option_value` SET is_reserved = 0
WHERE name = 'Urgent' AND option_group_id = (SELECT id FROM `civicrm_option_group` WHERE name = 'case_status');
-- CRM-11400
UPDATE `civicrm_state_province` SET name = 'Distrito Federal' WHERE name = 'Diatrito Federal';
-- CRM-9379 and CRM-11539
SELECT @option_group_id_act := MAX(id) FROM civicrm_option_group WHERE name = 'activity_type';
SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_act;
SELECT @max_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @CompId := MAX(id) FROM civicrm_component where name = 'CiviContribute';
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, is_reserved, component_id, filter)
VALUES
(@option_group_id_act, {localize field='label'}'Export Accounting Batch'{/localize}, @max_val+1, 'Export Accounting Batch', @max_wt+1, {localize field='description'}'Export Accounting Batch'{/localize}, 1, 1, @CompId, 1),
(@option_group_id_act, {localize field='label'}'Create Batch'{/localize}, @max_val+2, 'Create Batch', @max_wt+2, {localize field='description'}'Create Batch'{/localize}, 1, 1, @CompId, 1),
(@option_group_id_act, {localize field='label'}'Edit Batch'{/localize}, @max_val+3, 'Edit Batch', @max_wt+3, {localize field='description'}'Edit Batch'{/localize}, 1, 1, @CompId, 1);
-- CRM-11341
INSERT INTO
`civicrm_job` (domain_id, run_frequency, last_run, name, description, api_entity, api_action, parameters, is_active)
SELECT
id, 'Daily' , NULL, '{ts escape="sql" skip="true"}Disable expired relationships{/ts}', '{ts escape="sql" skip="true"}Disables relationships that have expired (ie. those relationships whose end date is in the past).{/ts}', 'job', 'disable_expired_relationships', NULL, 0
FROM `civicrm_domain`;
-- CRM-11367
SELECT @country_id := max(id) from civicrm_country where name = 'Latvia';
DELETE FROM civicrm_state_province WHERE name IN ('Ventspils Apripkis', 'Aizkraukles Apripkis', 'Alkanes Apripkis', 'Balvu Apripkis', 'Bauskas Apripkis', 'Cesu Aprikis', 'Daugavpile Apripkis', 'Dobeles Apripkis', 'Gulbenes Aprlpkis', 'Jelgavas Apripkis', 'Jekabpils Apripkis', 'Kraslavas Apripkis', 'Kuldlgas Apripkis', 'Limbazu Apripkis', 'Liepajas Apripkis', 'Ludzas Apripkis', 'Madonas Apripkis', 'Ogres Apripkis', 'Preilu Apripkis', 'Rezaknes Apripkis', 'Rigas Apripkis', 'Saldus Apripkis', 'Talsu Apripkis', 'Tukuma Apriplcis', 'Valkas Apripkis', 'Valmieras Apripkis');
INSERT IGNORE INTO civicrm_state_province (country_id, abbreviation, name) VALUES
(@country_id, '002', 'Aizkraukles novads'),
(@country_id, '038', 'Jaunjelgavas novads'),
(@country_id, '072', 'Pļaviņu novads'),
(@country_id, '046', 'Kokneses novads'),
(@country_id, '065', 'Neretas novads'),
(@country_id, '092', 'Skrīveru novads'),
(@country_id, '007', 'Alūksnes novads'),
(@country_id, '009', 'Apes novads'),
(@country_id, '015', 'Balvu novads'),
(@country_id, '108', 'Viļakas novads'),
(@country_id, '014', 'Baltinavas novads'),
(@country_id, '082', 'RugÄ<67>ju novads'),
(@country_id, '016', 'Bauskas novads'),
(@country_id, '034', 'Iecavas novads'),
(@country_id, '083', 'RundÄ<64>les novads'),
(@country_id, '105', 'Vecumnieku novads'),
(@country_id, '022', 'Cēsu novads'),
(@country_id, '055', 'Līgatnes novads'),
(@country_id, '008', 'Amatas novads'),
(@country_id, '039', 'Jaunpiebalgas novads'),
(@country_id, '075', 'Priekuļu novads'),
(@country_id, '070', 'PÄ<50>rgaujas novads'),
(@country_id, '076', 'Raunas novads'),
(@country_id, '104', 'Vecpiebalgas novads'),
(@country_id, '025', 'Daugavpils novads'),
(@country_id, '036', 'Ilūkstes novads'),
(@country_id, '026', 'Dobeles novads'),
(@country_id, '010', 'Auces novads'),
(@country_id, '098', 'Tērvetes novads'),
(@country_id, '033', 'Gulbenes novads'),
(@country_id, '041', 'Jelgavas novads'),
(@country_id, '069', 'Ozolnieku novads'),
(@country_id, '042', 'Jēkabpils novads'),
(@country_id, '004', 'Aknīstes novads'),
(@country_id, '107', 'Viesītes novads'),
(@country_id, '049', 'Krustpils novads'),
(@country_id, '085', 'Salas novads'),
(@country_id, '047', 'KrÄ<72>slavas novads'),
(@country_id, '024', 'Dagdas novads'),
(@country_id, '001', 'Aglonas novads'),
(@country_id, '050', 'Kuldīgas novads'),
(@country_id, '093', 'Skrundas novads'),
(@country_id, '006', 'Alsungas novads'),
(@country_id, '003', 'Aizputes novads'),
(@country_id, '028', 'Durbes novads'),
(@country_id, '032', 'Grobiņas novads'),
(@country_id, '071', 'PÄ<50>vilostas novads'),
(@country_id, '074', 'Priekules novads'),
(@country_id, '066', 'Nīcas novads'),
(@country_id, '081', 'Rucavas novads'),
(@country_id, '100', 'Vaiņodes novads'),
(@country_id, '054', 'Limbažu novads'),
(@country_id, '005', 'Alojas novads'),
(@country_id, '086', 'Salacgrīvas novads'),
(@country_id, '058', 'Ludzas novads'),
(@country_id, '044', 'KÄ<4B>rsavas novads'),
(@country_id, '110', 'Zilupes novads'),
(@country_id, '023', 'Ciblas novads'),
(@country_id, '059', 'Madonas novads'),
(@country_id, '021', 'Cesvaines novads'),
(@country_id, '057', 'LubÄ<62>nas novads'),
(@country_id, '102', 'VarakļÄ<C2BC>nu novads'),
(@country_id, '030', 'Ärgļu novads'),
(@country_id, '067', 'Ogres novads'),
(@country_id, '035', 'Ikšķiles novads'),
(@country_id, '051', 'Ķeguma novads'),
(@country_id, '053', 'LielvÄ<76>rdes novads'),
(@country_id, '073', 'Preiļu novads'),
(@country_id, '056', 'LÄ«vÄ<76>nu novads'),
(@country_id, '078', 'Riebiņu novads'),
(@country_id, '103', 'VÄ<56>rkavas novads'),
(@country_id, '077', 'Rēzeknes novads'),
(@country_id, '109', 'ViļÄ<C2BC>nu novads'),
(@country_id, '013', 'Baldones novads'),
(@country_id, '052', 'Ķekavas novads'),
(@country_id, '068', 'Olaines novads'),
(@country_id, '087', 'Salaspils novads'),
(@country_id, '089', 'Saulkrastu novads'),
(@country_id, '091', 'Siguldas novads'),
(@country_id, '037', 'InÄ<6E>ukalna novads'),
(@country_id, '011', 'Ādažu novads'),
(@country_id, '012', 'Babītes novads'),
(@country_id, '020', 'Carnikavas novads'),
(@country_id, '031', 'Garkalnes novads'),
(@country_id, '048', 'Krimuldas novads'),
(@country_id, '061', 'MÄ<4D>lpils novads'),
(@country_id, '062', 'MÄ<4D>rupes novads'),
(@country_id, '080', 'Ropažu novads'),
(@country_id, '090', 'Sējas novads'),
(@country_id, '095', 'Stopiņu novads'),
(@country_id, '088', 'Saldus novads'),
(@country_id, '018', 'Brocēnu novads'),
(@country_id, '097', 'Talsu novads'),
(@country_id, '027', 'Dundagas novads'),
(@country_id, '063', 'Mērsraga novads'),
(@country_id, '079', 'Rojas novads'),
(@country_id, '099', 'Tukuma novads'),
(@country_id, '043', 'Kandavas novads'),
(@country_id, '029', 'Engures novads'),
(@country_id, '040', 'Jaunpils novads'),
(@country_id, '101', 'Valkas novads'),
(@country_id, '094', 'Smiltenes novads'),
(@country_id, '096', 'StrenÄ<6E>u novads'),
(@country_id, '045', 'Kocēnu novads'),
(@country_id, '060', 'Mazsalacas novads'),
(@country_id, '084', 'Rūjienas novads'),
(@country_id, '017', 'Beverīnas novads'),
(@country_id, '019', 'Burtnieku novads'),
(@country_id, '064', 'Naukšēnu novads'),
(@country_id, '106', 'Ventspils novads'),
(@country_id, 'JKB', 'Jēkabpils'),
(@country_id, 'VMR', 'Valmiera');
-- CRM-11507
ALTER TABLE `civicrm_batch` CHANGE `type_id` `type_id` INT( 10 ) UNSIGNED NULL COMMENT 'fk to Batch Type options in civicrm_option_values';
UPDATE `civicrm_batch` SET `mode_id` = '1';
-- add Refunded in contribution status
SELECT @option_group_id_cs := MAX(id) FROM civicrm_option_group WHERE name = 'contribution_status';
SELECT @max_weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cs, {localize}'{ts escape="sql"}Refunded{/ts}'{/localize}, @max_weight + 1, 'Refunded', NULL, 0, NULL, @max_weight + 1, 0, 1, 1, NULL, NULL);
-- Payprocs from extensions may have long titles
ALTER TABLE civicrm_payment_processor_type MODIFY COLUMN title varchar(127);
-- CRM-11665
ALTER TABLE `civicrm_address`
ADD COLUMN manual_geo_code tinyint(4) DEFAULT '0' COMMENT 'Is this a manually entered geo code.';
-- CRM-11761
UPDATE `civicrm_setting` SET `group_name` = 'Personal Preferences' WHERE `group_name` = 'Navigation Menu';
-- CRM-11779
INSERT INTO civicrm_action_mapping ( entity, entity_value, entity_value_label, entity_status, entity_status_label, entity_date_start, entity_date_end, entity_recipient )
VALUES
( 'civicrm_participant', 'event_template', 'Event Template', 'civicrm_participant_status_type', 'Participant Status', 'event_start_date', 'event_end_date', 'event_contacts');
-- CRM-11802 Fix ON DELETE CASCADE constraint for line_item.price_field_id
ALTER TABLE `civicrm_line_item`
DROP FOREIGN KEY `FK_civicrm_line_item_price_field_id`,
CHANGE `price_field_id` `price_field_id` INT( 10 ) UNSIGNED DEFAULT NULL;
ALTER TABLE `civicrm_line_item`
ADD CONSTRAINT `FK_civicrm_line_item_price_field_id` FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field`(id) ON DELETE SET NULL;
-- CRM-11821
-- update all location info of domain
-- like address, email, phone etc.
UPDATE civicrm_domain cd
LEFT JOIN civicrm_loc_block clb ON cd.loc_block_id = clb.id
LEFT JOIN civicrm_address ca ON clb.address_id = ca.id
LEFT JOIN civicrm_phone cp ON cp.id = clb.phone_id
LEFT JOIN civicrm_email ce ON ce.id = clb.email_id
SET
ca.contact_id = cd.contact_id, cp.contact_id = cd.contact_id, ce.contact_id = cd.contact_id;
-- Delete rows from civicrm_loc_block used for civicrm_domain
DELETE clb.* FROM civicrm_domain cd
LEFT JOIN civicrm_loc_block clb ON clb.id = cd.loc_block_id;
-- Delete loc_block_id from civicrm_domain
ALTER TABLE `civicrm_domain` DROP loc_block_id;
-- CRM11818
-- pledge payments should not be cancelled if the contribution was
-- compledged but the pledge is cancelled
UPDATE
civicrm_pledge_payment pp
INNER JOIN civicrm_contribution c ON
c.id = pp.contribution_id AND pp.status_id =3
AND contribution_status_id = 1
SET pp.status_id = contribution_status_id

View file

@ -0,0 +1,40 @@
-- CRM-11847
UPDATE `civicrm_dedupe_rule_group`
SET name = 'IndividualGeneral'
WHERE name = 'IndividualComplete';
-- CRM-11791
INSERT IGNORE INTO `civicrm_relationship_type` ( name_a_b,label_a_b, name_b_a,label_b_a, description, contact_type_a, contact_type_b, is_reserved )
VALUES
( 'Partner of', '{ts escape="sql"}Partner of{/ts}', 'Partner of', '{ts escape="sql"}Partner of{/ts}', '{ts escape="sql"}Partner relationship.{/ts}', 'Individual', 'Individual', 0 );
-- CRM-11886
UPDATE `civicrm_navigation`
SET permission = 'view own manual batches,view all manual batches'
WHERE
name = 'Open Batches' OR
name = 'Closed Batches' OR
name = 'Exported Batches' OR
name = 'Accounting Batches';
UPDATE `civicrm_navigation`
SET permission = 'create manual batch'
WHERE
name = 'Accounting Batches';
-- CRM-11891
SELECT @contributionlastID := max(id) from civicrm_navigation where name = 'Contributions' AND domain_id = {$domainID};
SELECT @importWeight := weight from civicrm_navigation where name = 'Import Contributions' and parent_id = @contributionlastID;
-- since 'Bulk Data Entry' was renamed to 'Batch Data Entry'
UPDATE `civicrm_navigation` SET label = '{ts escape="sql"}Batch Data Entry{/ts}', name = 'Batch Data Entry'
WHERE url = 'civicrm/batch&reset=1';
UPDATE `civicrm_navigation`
SET `weight` = `weight`+2
WHERE `parent_id` = @contributionlastID
AND (`weight` > @importWeight OR `name` = 'Accounting Batches');
UPDATE `civicrm_navigation`
SET `weight` = @importWeight+1
WHERE `name` = 'Batch Data Entry';

View file

@ -0,0 +1,4 @@
{include file='../CRM/Upgrade/4.3.alpha3.msg_template/civicrm_msg_template.tpl'}
-- CRM-11906
ALTER TABLE `civicrm_batch` CHANGE `item_count` `item_count` INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'Number of items in a batch.';

View file

@ -0,0 +1 @@
{include file='../CRM/Upgrade/4.3.beta1.msg_template/civicrm_msg_template.tpl'}

View file

@ -0,0 +1 @@
{include file='../CRM/Upgrade/4.3.beta2.msg_template/civicrm_msg_template.tpl'}

View file

@ -0,0 +1,31 @@
{include file='../CRM/Upgrade/4.3.beta3.msg_template/civicrm_msg_template.tpl'}
-- CRM-12077
DELETE cog, cov FROM `civicrm_option_group` cog
LEFT JOIN civicrm_option_value cov ON cov.option_group_id = cog.id
WHERE cog.name = 'account_type';
{if $multilingual}
UPDATE civicrm_uf_field
SET field_name = 'financial_type'
WHERE field_name LIKE 'contribution_type';
{foreach from=$locales item=locale}
UPDATE civicrm_uf_field
SET label_{$locale} = 'Financial Type'
WHERE field_name = 'financial_type' AND label_{$locale} = 'Contribution Type';
{/foreach}
{else}
UPDATE civicrm_uf_field
SET field_name = 'financial_type',
label = CASE
WHEN label = 'Contribution Type'
THEN 'Financial Type'
ELSE label
END
WHERE field_name = 'contribution_type';
{/if}
-- CRM-12065
UPDATE `civicrm_mapping_field`
SET name = replace(name, 'contribution_type', 'financial_type')
where name LIKE '%contribution_type%';

View file

@ -0,0 +1,25 @@
-- CRM-12151
ALTER TABLE civicrm_option_value
DROP INDEX index_option_group_id_value,
ADD INDEX index_option_group_id_value (value(128), option_group_id),
DROP INDEX index_option_group_id_name,
ADD INDEX index_option_group_id_name (option_group_id, name(128));
-- CRM-12127
UPDATE civicrm_membership_type cmt
LEFT JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cmt.id
LEFT JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id
LEFT JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id
SET
cpfv.financial_type_id = cmt.financial_type_id,
{if !$multilingual}
cpfv.label = cmt.name,
cpfv.description = cmt.description,
{else}
{foreach from=$locales item=locale}
cpfv.label_{$locale} = cmt.name_{$locale},
cpfv.description_{$locale} = cmt.description_{$locale},
{/foreach}
{/if}
cpfv.amount = IFNULL(cmt.minimum_fee, 0.00)
WHERE cps.is_quick_config = 1 AND cpfv.membership_type_id IS NOT NULL;

View file

@ -0,0 +1,9 @@
-- CRM-12142
-- Populate default text for premiums_nothankyou_label
UPDATE `civicrm_premiums` SET {localize field="premiums_nothankyou_label"}premiums_nothankyou_label = '{ts escape="sql"}No thank-you{/ts}'{/localize};
-- CRM-12233 Fix price field label for quick config membership signup field
UPDATE `civicrm_price_field` cpf
LEFT JOIN `civicrm_price_set` cps ON cps.id = cpf.price_set_id
SET {localize field="label"}cpf.label = '{ts escape="sql"}Membership{/ts}'{/localize}
WHERE cps.is_quick_config = 1 AND cpf.name = 'membership_amount';

View file

@ -0,0 +1,9 @@
{* file to handle db changes in 4.4.0 during upgrade *}
-- CRM-13571
UPDATE civicrm_state_province SET name = 'Møre og Romsdal' WHERE name = 'Møre ag Romsdal';
-- CRM-13604
UPDATE civicrm_state_province SET name = 'Alta Verapaz' WHERE name = 'Alta Verapez';
UPDATE civicrm_state_province SET name = 'Baja Verapaz' WHERE name = 'Baja Verapez';
UPDATE civicrm_state_province SET name = 'Retalhuleu' WHERE name = 'Reta.thuleu';
UPDATE civicrm_state_province SET name = 'Sololá' WHERE name = 'Solol6';

View file

@ -0,0 +1,12 @@
{* file to handle db changes in 4.4.1 during upgrade *}
-- CRM-13327
SELECT @option_group_id_name_badge := max(id) from civicrm_option_group where name = 'name_badge';
UPDATE civicrm_option_value
SET value = '{literal}{"name":"Avery 5395","paper-size":"a4","metric":"mm","lMargin":15,"tMargin":26,"NX":2,"NY":4,"SpaceX":10,"SpaceY":5,"width":83,"height":57,"font-size":12,"orientation":"portrait","font-name":"helvetica","font-style":"","lPadding":3,"tPadding":3}{/literal}'
WHERE option_group_id = @option_group_id_name_badge AND name = 'Avery 5395';
-- CRM-13669
{literal}
UPDATE civicrm_option_value SET name = 'Dear {contact.household_name}'
WHERE name = 'Dear {contact.househols_name}';
{/literal}

View file

@ -0,0 +1,5 @@
{* file to handle db changes in 4.4.2 during upgrade *}
-- CRM-13758
UPDATE civicrm_uf_field SET field_name = 'gender_id' WHERE field_name = 'gender';
UPDATE civicrm_uf_field SET field_name = 'prefix_id' WHERE field_name = 'individual_prefix';
UPDATE civicrm_uf_field SET field_name = 'suffix_id' WHERE field_name = 'individual_suffix';

View file

@ -0,0 +1,8 @@
{* file to handle db changes in 4.4.3 during upgrade *}
{include file='../CRM/Upgrade/4.4.3.msg_template/civicrm_msg_template.tpl'}
-- CRM-13420
UPDATE civicrm_option_value
INNER JOIN civicrm_option_group ON civicrm_option_value.option_group_id = civicrm_option_group.id
SET civicrm_option_value.is_default = 1
WHERE civicrm_option_group.name = 'payment_instrument' AND civicrm_option_value.name = 'Check';

View file

@ -0,0 +1,28 @@
{* file to handle db changes in 4.4.4 during upgrade *}
{* update comment for civicrm_report_instance.grouprole *}
ALTER TABLE civicrm_report_instance MODIFY grouprole varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'role required to be able to run this instance';
{* CRM-14117 *}
UPDATE civicrm_navigation SET url = 'http://civicrm.org/what/whatiscivicrm' WHERE name = 'About';
-- CRM-13968
SELECT @inprogressstatus := value FROM civicrm_option_value cov
LEFT JOIN civicrm_option_group cg ON cov.option_group_id = cg.id
WHERE cg.name = 'contribution_status' AND cov.name = 'In Progress';
SELECT @financialstatus := value FROM civicrm_option_value cov
LEFT JOIN civicrm_option_group cg ON cov.option_group_id = cg.id
WHERE cg.name = 'financial_item_status' AND cov.name = 'Unpaid';
SELECT @accountrecievable := id FROM `civicrm_financial_account` WHERE `name` LIKE 'Accounts Receivable';
UPDATE civicrm_financial_trxn cft
LEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.financial_trxn_id = cft.id
LEFT JOIN civicrm_entity_financial_trxn ceft_financial_item ON ceft_financial_item.financial_trxn_id = cft.id
LEFT JOIN civicrm_financial_item cfi ON cfi.id = ceft_financial_item.entity_id
SET to_financial_account_id = @accountrecievable, cfi.status_id = @financialstatus
WHERE ceft.entity_table = 'civicrm_contribution' AND ceft_financial_item.entity_table = 'civicrm_financial_item' AND cft.status_id = @inprogressstatus AND cfi.status_id IS NULL;
{* CRM-14167 *}
ALTER TABLE civicrm_activity_contact ADD INDEX index_record_type ( activity_id, record_type_id );

View file

@ -0,0 +1,36 @@
{* file to handle db changes in 4.4.5 during upgrade *}
-- CRM-14191
SELECT @option_group_id_batch_status := max(id) from civicrm_option_group where name = 'batch_status';
SELECT @weight := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value
SET value = (Select @weight := @weight +1),
weight = @weight
WHERE option_group_id = @option_group_id_batch_status AND name IN ('Data Entry', 'Reopened', 'Exported') AND value = 0 ORDER BY id;
SELECT @option_group_id_batch_modes := max(id) from civicrm_option_group where name = 'batch_mode';
SELECT @weights := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_modes;
UPDATE civicrm_option_value
SET value = (Select @weights := @weights +1),
weight = @weights
WHERE option_group_id = @option_group_id_batch_modes AND name IN ('Manual Batch', 'Automatic Batch') AND value = 0;
SELECT @manual_mode_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_modes AND name = 'Manual Batch';
UPDATE civicrm_batch SET mode_id = @manual_mode_id WHERE (mode_id IS NULL OR mode_id = 0) AND type_id IS NULL;
SELECT @data_entry_status_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status AND name = 'Data Entry';
UPDATE civicrm_batch SET status_id = @data_entry_status_id WHERE status_id = 3 AND type_id IS NOT NULL;
SELECT @exported_status_id := MAX(value) FROM civicrm_option_value WHERE option_group_id = @option_group_id_batch_status AND name = 'Exported';
UPDATE civicrm_navigation SET url = CONCAT('civicrm/financial/financialbatches?reset=1&batchStatus=', @exported_status_id) WHERE name = 'Exported Batches';
-- update status_id to Exported
SELECT @export_activity_type := max(value) FROM civicrm_option_value cov
INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id
WHERE cog.name = 'activity_type' AND cov.name = 'Export Accounting Batch';
UPDATE civicrm_batch cb
INNER JOIN civicrm_activity ca ON ca.source_record_id = cb.id
SET cb.status_id = @exported_status_id
WHERE cb.status_id = 0 AND ca.activity_type_id = @export_activity_type;

View file

@ -0,0 +1,5 @@
{* CRM-16846 - This file is never run, but it doesn't matter because the below query is undone by another alteration to the same column in 4.5.alpha1 *}
-- CRM-14903
ALTER TABLE `civicrm_mapping_field`
CHANGE COLUMN `operator` `operator` ENUM('=','!=','>','<','>=','<=','IN','NOT IN','LIKE','NOT LIKE','IS NULL','IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY', 'RLIKE');

View file

@ -0,0 +1,6 @@
{* file to handle db changes in 4.4.7 during upgrade *}
-- CRM-13571
UPDATE civicrm_state_province SET name = 'Møre og Romsdal' WHERE name = 'M<>re og Romsdal';
-- CRM-13604
UPDATE civicrm_state_province SET name = 'Sololá' WHERE name = 'Solol<6F>';

View file

@ -0,0 +1,161 @@
{include file='../CRM/Upgrade/4.4.alpha1.msg_template/civicrm_msg_template.tpl'}
-- CRM-12357
SELECT @option_group_id_cvOpt := max(id) FROM civicrm_option_group WHERE name = 'contact_view_options';
SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_cvOpt;
SELECT @max_wt := MAX(ROUND(val.weight)) FROM civicrm_option_value val WHERE val.option_group_id = @option_group_id_cvOpt;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cvOpt, {localize}'{ts escape="sql"}Mailings{/ts}'{/localize}, @max_val+1, 'CiviMail', NULL, 0, NULL, @max_wt+1, 0, 0, 1, NULL, NULL);
INSERT INTO civicrm_setting
(domain_id, contact_id, is_domain, group_name, name, value)
VALUES
({$domainID}, NULL, 1, 'Mailing Preferences', 'write_activity_record', '{serialize}1{/serialize}');
-- CRM-12580
ALTER TABLE civicrm_contact ADD INDEX index_is_deleted_sort_name(is_deleted, sort_name, id);
ALTER TABLE civicrm_contact DROP INDEX index_is_deleted;
-- CRM-12495
DROP TABLE IF EXISTS `civicrm_task_status`;
DROP TABLE IF EXISTS `civicrm_task`;
DROP TABLE IF EXISTS `civicrm_project`;
-- CRM-12425
SELECT @bounceTypeID := max(id) FROM civicrm_mailing_bounce_type WHERE name = 'Spam';
INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern)
VALUES (@bounceTypeID, 'X-HmXmrOriginalRecipient');
-- CRM-12716
UPDATE civicrm_custom_field SET text_length = NULL WHERE html_type = 'TextArea' AND text_length = 255;
-- CRM-12288
SELECT @option_group_id_activity_type := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_activity_type;
SELECT @max_wt := max(weight) from civicrm_option_value where option_group_id=@option_group_id_activity_type;
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, value, name, weight, filter, component_id)
VALUES
(@option_group_id_activity_type, {localize}'Inbound SMS'{/localize},{localize}'Inbound SMS'{/localize}, (SELECT @max_val := @max_val+1), 'Inbound SMS', (SELECT @max_wt := @max_wt+1), 1, NULL),
(@option_group_id_activity_type, {localize}'SMS delivery'{/localize},{localize}'SMS delivery'{/localize}, (SELECT @max_val := @max_val+1), 'SMS delivery', (SELECT @max_wt := @max_wt+1), 1, NULL);
-- CRM-13015 replaced if $multilingual w/ localize method
UPDATE `civicrm_option_value` SET {localize field="label"}label = '{ts escape="sql"}Outbound SMS{/ts}'{/localize}
WHERE name = 'SMS' and option_group_id = @option_group_id_activity_type;
-- CRM-12689
ALTER TABLE civicrm_action_schedule
ADD COLUMN limit_to tinyint(4) DEFAULT '1' COMMENT 'Is this the recipient criteria limited to OR in addition to?' AFTER recipient;
-- CRM-12653
SELECT @uf_group_contribution_batch_entry := max(id) FROM civicrm_uf_group WHERE name = 'contribution_batch_entry';
SELECT @uf_group_membership_batch_entry := max(id) FROM civicrm_uf_group WHERE name = 'membership_batch_entry';
INSERT INTO civicrm_uf_field
( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, {localize field='label'}label{/localize}, field_type)
VALUES
( @uf_group_contribution_batch_entry, 'soft_credit', 0, 0, 10, 'User and User Admin Only', 0, 0, NULL, {localize}'Soft Credit'{/localize}, 'Contribution'),
( @uf_group_membership_batch_entry, 'soft_credit', 0, 0, 13, 'User and User Admin Only', 0, 0, NULL, {localize}'Soft Credit'{/localize}, 'Membership');
-- CRM-12809
ALTER TABLE `civicrm_custom_group`
ADD COLUMN `is_reserved` tinyint(4) DEFAULT '0' COMMENT 'Is this a reserved Custom Group?';
--CRM-12986 fix event_id & contact_id to NOT NULL fields on participant table
SET foreign_key_checks = 0;
ALTER TABLE `civicrm_participant`
CHANGE COLUMN `event_id` `event_id` INT(10) UNSIGNED NOT NULL,
CHANGE COLUMN `contact_id` `contact_id` INT(10) UNSIGNED NOT NULL;
SET foreign_key_checks = 1;
-- CRM-12964 civicrm_print_label table creation
CREATE TABLE IF NOT EXISTS `civicrm_print_label` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'User title for for this label layout',
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'variable name/programmatic handle for this field.',
`description` text COLLATE utf8_unicode_ci COMMENT 'Description of this label layout',
`label_format_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'This refers to name column of civicrm_option_value row in name_badge option group',
`label_type_id` int(10) unsigned DEFAULT NULL COMMENT 'Implicit FK to civicrm_option_value row in NEW label_type option group',
`data` longtext COLLATE utf8_unicode_ci COMMENT 'contains json encode configurations options',
`is_default` tinyint(4) DEFAULT '1' COMMENT 'Is this default?',
`is_active` tinyint(4) DEFAULT '1' COMMENT 'Is this option active?',
`is_reserved` tinyint(4) DEFAULT '1' COMMENT 'Is this reserved label?',
`created_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to civicrm_contact, who created this label layout',
PRIMARY KEY (`id`),
KEY `FK_civicrm_print_label_created_id` (`created_id`),
CONSTRAINT `FK_civicrm_print_label_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-- CRM-12964 adding meta-data
INSERT INTO
`civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
VALUES
('label_type', {localize}'{ts escape="sql"}Label Type{/ts}'{/localize}, 1, 1),
('name_badge', {localize}'{ts escape="sql"}Name Badge Format{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_label_type := max(id) from civicrm_option_group where name = 'label_type';
SELECT @option_group_id_name_badge := max(id) from civicrm_option_group where name = 'name_badge';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_label_type, {localize}'{ts escape="sql"}Event Badge{/ts}'{/localize}, 1, 'Event Badge', NULL, 0, NULL, 1, 0, 0, 1, NULL, NULL),
(@option_group_id_name_badge, {localize}'{ts escape="sql"}Avery 5395{/ts}'{/localize}, '{literal}{"name":"Avery 5395","paper-size":"a4","metric":"mm","lMargin":13.5,"tMargin":3,"NX":2,"NY":4,"SpaceX":15,"SpaceY":8.5,"width":85.7,"height":59.2,"font-size":12,"orientation":"portrait","font-name":"helvetica","font-style":"","lPadding":0,"tPadding":0}{/literal}', 'Avery 5395', NULL, 0, NULL, 1, 0, 0, 1, NULL, NULL);
-- CRM-12964 adding navigation
UPDATE civicrm_navigation
SET url = 'civicrm/admin/badgelayout&reset=1',
name = 'Event Name Badge Layouts',
label= '{ts escape="sql" skip="true"}Event Name Badge Layouts{/ts}'
WHERE name = 'Event Badge Formats';
--CRM-12539 change 'Greater London' to 'London'
UPDATE `civicrm_state_province` SET `name` = 'London' WHERE `name` = 'Greater London';
UPDATE `civicrm_premiums` SET {localize field="premiums_nothankyou_label"}premiums_nothankyou_label = '{ts escape="sql"}No thank-you{/ts}'{/localize};
-- CRM-13015 Change address option labels from Additional Address to Supplemental Address
SELECT @option_group_id_addroptions := max(id) from civicrm_option_group where name = 'address_options';
UPDATE civicrm_option_value
SET {localize field="label"}label = '{ts escape="sql"}Supplemental Address 1{/ts}'{/localize}
WHERE name = 'supplemental_address_1' AND option_group_id = @option_group_id_addroptions;
UPDATE civicrm_option_value
SET {localize field="label"}label = '{ts escape="sql"}Supplemental Address 2{/ts}'{/localize}
WHERE name = 'supplemental_address_2' AND option_group_id = @option_group_id_addroptions;
-- CRM-12717
UPDATE `civicrm_navigation` SET label = '{ts escape="sql"}Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.){/ts}', name = 'Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)'
WHERE url = 'civicrm/admin/setting/misc&reset=1';
-- CRM-13112
ALTER TABLE civicrm_survey
ADD is_share TINYINT( 4 ) NULL DEFAULT '1' COMMENT 'Can people share the petition through social media?';
-- CRM-12439
{if $multilingual}
ALTER TABLE `civicrm_uf_group`
ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Optional verbose description of the profile.' AFTER `group_type`;
{else}
ALTER TABLE `civicrm_uf_group`
ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Optional verbose description of the profile.' AFTER `title`;
{/if}
--CRM-13142
UPDATE
civicrm_uf_field uf
INNER JOIN
civicrm_uf_group ug ON uf.uf_group_id = ug.id AND ug.is_reserved = 1 AND name = 'membership_batch_entry'
SET uf.is_reserved = 0
WHERE uf.field_name IN ('join_date', 'membership_start_date', 'membership_end_date');
--CRM-13155 - Add searching for recurring contribution data to search has been successfully created.
ALTER TABLE `civicrm_contribution_recur`
CHANGE COLUMN `next_sched_contribution` `next_sched_contribution_date` DATETIME NULL DEFAULT NULL COMMENT 'At Groundspring this was used by the cron job which triggered payments. If we\'re not doing that but we know about payments, it might still be useful to store for display to org andor contributors.' AFTER `cycle_day`;

View file

@ -0,0 +1,9 @@
{* file to handle db changes in 4.4.beta1 during upgrade *}
-- CRM-13314 Added States for Uruguay
INSERT IGNORE INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
(NULL, 1229, "FL", "Florida"),
(NULL, 1229, "RN", "Rio Negro"),
(NULL, 1229, "SJ", "San Jose");
ALTER TABLE civicrm_email
MODIFY email VARCHAR(254);

View file

@ -0,0 +1,11 @@
{* file to handle db changes in 4.5.0 during upgrade *}
{include file='../CRM/Upgrade/4.5.0.msg_template/civicrm_msg_template.tpl'}
ALTER TABLE `civicrm_action_schedule`
ADD COLUMN `sms_template_id` int(10) unsigned DEFAULT NULL COMMENT 'SMS Reminder Template. FK to id in civicrm_msg_template.' AFTER `msg_template_id`,
ADD COLUMN `sms_body_text` longtext COLLATE utf8_unicode_ci COMMENT 'Body of the mailing in html format.' AFTER `body_html`,
ADD CONSTRAINT `FK_civicrm_action_schedule_sms_template_id` FOREIGN KEY (`sms_template_id`) REFERENCES civicrm_msg_template(`id`) ON DELETE SET NULL;
ALTER TABLE `civicrm_msg_template`
ADD COLUMN `is_sms` tinyint(4) DEFAULT '0' COMMENT 'Is this message template used for sms?';

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.1 during upgrade *}

View file

@ -0,0 +1,5 @@
{* file to handle db changes in 4.5.2 during upgrade *}
-- CRM-15467 Also fix group_type for Honoree Profile
UPDATE civicrm_uf_group SET group_type = 'Individual,Contact' WHERE name = 'honoree_individual';

View file

@ -0,0 +1,12 @@
{* file to handle db changes in 4.5.3 during upgrade *}
-- CRM-15475
SELECT @membershipStatusId := id FROM civicrm_membership_status WHERE name = 'Cancelled';
SELECT @membershipStatusWeight := max(weight) + 1 FROM civicrm_membership_status;
INSERT INTO civicrm_membership_status (id, name, {localize field='label'}label{/localize}, start_event, start_event_adjust_unit, start_event_adjust_interval, end_event, end_event_adjust_unit, end_event_adjust_interval, is_current_member, is_admin, weight, is_default, is_active, is_reserved)
VALUES (@membershipStatusId, 'Cancelled', {localize}'{ts escape="sql"}Cancelled{/ts}'{/localize}, 'join_date', null, null, 'join_date', null, null, 0, 0, @membershipStatusWeight, 0, 0, 1)
ON DUPLICATE KEY UPDATE is_reserved = 1;
-- CRM-15558
ALTER TABLE `civicrm_mailing_bounce_type` CHANGE `name` `name` VARCHAR( 24 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Type of bounce';

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.4 during upgrade *}

View file

@ -0,0 +1,5 @@
{* file to handle db changes in 4.5.5 during upgrade *}
-- https://issues.civicrm.org/jira/browse/CRM-15630
UPDATE civicrm_msg_template SET msg_html = REPLACE(msg_html, 'email=true', 'emailMode=true') WHERE msg_title = 'Petition - signature added';

View file

@ -0,0 +1,4 @@
{* file to handle db changes in 4.5.6 during upgrade *}
-- CRM-15760
ALTER TABLE `civicrm_action_schedule` CHANGE `entity_value` `entity_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Entity value';

View file

@ -0,0 +1,6 @@
{* file to handle db changes in 4.5.7 during upgrade *}
-- CRM-15931
UPDATE civicrm_mailing_group SET group_type = 'Include' WHERE group_type = 'include';
UPDATE civicrm_mailing_group SET group_type = 'Exclude' WHERE group_type = 'exclude';
UPDATE civicrm_mailing_group SET group_type = 'Base' WHERE group_type = 'base';

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.8 during upgrade *}

View file

@ -0,0 +1 @@
{* CRM-16846 - This file is never run, but it doesn't matter because it's empty *}

View file

@ -0,0 +1,541 @@
{* file to handle db changes in 4.5.alpha1 during upgrade *}
{include file='../CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl'}
ALTER TABLE `civicrm_contact`
ADD COLUMN `formal_title` varchar(64) COMMENT 'Formal (academic or similar) title in front of name. (Prof., Dr. etc.)' AFTER `suffix_id`;
ALTER TABLE `civicrm_contact`
ADD COLUMN `communication_style_id` int(10) unsigned COMMENT 'Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.' AFTER `formal_title`,
ADD INDEX `index_communication_style_id` (`communication_style_id`);
INSERT INTO
`civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
VALUES
('communication_style', {localize}'{ts escape="sql"}Communication Style{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_communication_style := max(id) from civicrm_option_group where name = 'communication_style';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_communication_style, {localize}'{ts escape="sql"}Formal{/ts}'{/localize}, 1, 'formal' , NULL, 0, 1, 1, 0, 0, 1, NULL, NULL),
(@option_group_id_communication_style, {localize}'{ts escape="sql"}Familiar{/ts}'{/localize}, 2, 'familiar', NULL, 0, 0, 2, 0, 0, 1, NULL, NULL);
-- Insert menu item at Administer > Communications, above the various Greeting Formats
SELECT @parent_id := `id` FROM `civicrm_navigation` WHERE `name` = 'Communications' AND `domain_id` = {$domainID};
SELECT @add_weight := MIN(`weight`) FROM `civicrm_navigation` WHERE `name` IN('Email Greeting Formats', 'Postal Greeting Formats', 'Addressee Formats') AND `parent_id` = @parent_id;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+1
WHERE `parent_id` = @parent_id
AND `weight` >= @add_weight;
INSERT INTO `civicrm_navigation`
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/admin/options/communication_style&group=communication_style&reset=1', '{ts escape="sql" skip="true"}Communication Style Options{/ts}', 'Communication Style Options', 'administer CiviCRM', '', @parent_id, '1', NULL, @add_weight );
-- CRM-9988 Change world region of Panama country to America South, Central, North and Caribbean
UPDATE `civicrm_country` SET `region_id` = 2 WHERE `id` = 1166;
SELECT @option_group_id_contact_edit_options := max(id) from civicrm_option_group where name = 'contact_edit_options';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}Prefix{/ts}'{/localize} , 12, 'Prefix' , NULL, 2, NULL, 12, 0, 0, 1, NULL, NULL),
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}Formal Title{/ts}'{/localize}, 13, 'Formal Title', NULL, 2, NULL, 13, 0, 0, 1, NULL, NULL),
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}First Name{/ts}'{/localize} , 14, 'First Name' , NULL, 2, NULL, 14, 0, 0, 1, NULL, NULL),
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}Middle Name{/ts}'{/localize} , 15, 'Middle Name' , NULL, 2, NULL, 15, 0, 0, 1, NULL, NULL),
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}Last Name{/ts}'{/localize} , 16, 'Last Name' , NULL, 2, NULL, 16, 0, 0, 1, NULL, NULL),
(@option_group_id_contact_edit_options, {localize}'{ts escape="sql"}Suffix{/ts}'{/localize} , 17, 'Suffix' , NULL, 2, NULL, 17, 0, 0, 1, NULL, NULL);
-- CRM-13857
ALTER TABLE civicrm_group
ADD COLUMN `modified_id` INT(10) unsigned DEFAULT NULL COMMENT 'FK to contact table, modifier of the group.',
ADD CONSTRAINT `FK_civicrm_group_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL;
-- CRM-13913
ALTER TABLE civicrm_word_replacement
ALTER COLUMN `is_active` SET DEFAULT 1;
--CRM-13833 Implement Soft Credit Type for Contribution
INSERT INTO civicrm_option_group
(name, {localize field='title'}title{/localize}, is_reserved, is_active) VALUES ('soft_credit_type', {localize}'{ts escape="sql"}Soft Credit Types{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_soft_credit_type := max(id) from civicrm_option_group where name = 'soft_credit_type';
INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `weight`, `is_default`, `is_active`, `is_reserved`)
VALUES
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}In Honor of{/ts}'{/localize}, 1, 'in_honor_of', 1, 0, 1, 1),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}In Memory of{/ts}'{/localize}, 2, 'in_memory_of', 2, 0, 1, 1),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Solicited{/ts}'{/localize}, 3, 'solicited', 3, 0, 1, 1),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Household{/ts}'{/localize}, 4, 'household', 4, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Workplace Giving{/ts}'{/localize}, 5, 'workplace', 5, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Foundation Affiliate{/ts}'{/localize}, 6, 'foundation_affiliate', 6, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}3rd-party Service{/ts}'{/localize}, 7, '3rd-party_service', 7, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Donor-advised Fund{/ts}'{/localize}, 8, 'donor-advised_fund', 8, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Matched Gift{/ts}'{/localize}, 9, 'matched_gift', 9, 0, 1, 0),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Personal Campaign Page{/ts}'{/localize}, 10, 'pcp', 10, 0, 1, 1),
(@option_group_id_soft_credit_type , {localize}'{ts escape="sql"}Gift{/ts}'{/localize}, 11, 'gift', 11, 0, 1, 1);
ALTER TABLE `civicrm_contribution_soft`
ADD COLUMN `soft_credit_type_id` int(10) unsigned COMMENT 'Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.';
INSERT INTO civicrm_contribution_soft(contribution_id, contact_id, amount, currency, soft_credit_type_id)
SELECT id, honor_contact_id, total_amount, currency, honor_type_id
FROM civicrm_contribution
WHERE honor_contact_id IS NOT NULL;
SELECT @sct_pcp_id := value from civicrm_option_value where name = 'pcp' and option_group_id = @option_group_id_soft_credit_type;
UPDATE `civicrm_contribution_soft`
SET soft_credit_type_id = @sct_pcp_id
WHERE pcp_id IS NOT NULL;
--CRM-13734 make basic Case Activity Types reserved
SELECT @option_group_id_activity_type := id from civicrm_option_group where name = 'activity_type';
SELECT @caseCompId := id FROM `civicrm_component` where `name` like 'CiviCase';
UPDATE `civicrm_option_value`
SET is_reserved = 1
WHERE is_reserved = 0 AND option_group_id = @option_group_id_activity_type AND component_id = @caseCompId;
-- CRM-13912
ALTER TABLE civicrm_action_schedule
ADD COLUMN `mode` varchar(128) COLLATE utf8_unicode_ci DEFAULT 'Email' COMMENT 'Send the message as email or sms or both.';
INSERT INTO
civicrm_option_group (name, {localize field='title'}title{/localize}, is_reserved, is_active)
VALUES
('msg_mode', {localize}'{ts escape="sql"}Message Mode{/ts}'{/localize}, 1, 1);
SELECT @option_group_id_msg_mode := max(id) from civicrm_option_group where name = 'msg_mode';
INSERT INTO
civicrm_option_value (option_group_id, {localize field='label'}`label`{/localize}, value, name, is_default, weight, is_reserved, is_active)
VALUES
(@option_group_id_msg_mode, {localize}'{ts escape="sql"}Email{/ts}'{/localize}, 'Email', 'Email', 1, 1, 1, 1),
(@option_group_id_msg_mode, {localize}'{ts escape="sql"}SMS{/ts}'{/localize},'SMS', 'SMS', 0, 2, 1, 1),
(@option_group_id_msg_mode, {localize}'{ts escape="sql"}User Preference{/ts}'{/localize}, 'User_Preference', 'User Preference', 0, 3, 1, 1);
ALTER TABLE civicrm_action_schedule ADD sms_provider_id int(10) unsigned NULL COMMENT 'FK to civicrm_sms_provider id ';
ALTER TABLE civicrm_action_schedule ADD CONSTRAINT FK_civicrm_action_schedule_sms_provider_id FOREIGN KEY (`sms_provider_id`) REFERENCES `civicrm_sms_provider` (`id`) ON DELETE SET NULL;
--CRM-13981 migrate 'In Honor of' to Soft Credits
INSERT INTO `civicrm_uf_group`
(`name`, `group_type`, {localize field='title'}`title`{/localize}, `is_cms_user`, `is_reserved`)
VALUES
('honoree_individual', 'Individual,Contact', {localize}'{ts escape="sql"}Honoree Individual{/ts}'{/localize}, 0, 1);
SELECT @uf_group_id_honoree_individual := id from civicrm_uf_group where name = 'honoree_individual';
SELECT @primaryLocation := id FROM civicrm_location_type WHERE is_default = 1;
INSERT INTO `civicrm_uf_field`
(`uf_group_id`, `field_name`, `is_required`, `is_reserved`, `weight`, `visibility`, `in_selector`, `is_searchable`, `location_type_id`, {localize field='label'}`label`{/localize}, field_type)
VALUES
(@uf_group_id_honoree_individual, 'prefix_id', 0, 1, 1, 'User and User Admin Only', 0, 1, NULL, {localize}'{ts escape="sql"}Individual Prefix{/ts}'{/localize}, 'Individual'),
(@uf_group_id_honoree_individual, 'first_name', 0, 1, 2, 'User and User Admin Only', 0, 1, NULL, {localize}'{ts escape="sql"}First Name{/ts}'{/localize}, 'Individual'),
(@uf_group_id_honoree_individual, 'last_name', 0, 1, 3, 'User and User Admin Only', 0, 1, NULL, {localize}'{ts escape="sql"}Last Name{/ts}'{/localize}, 'Individual'),
(@uf_group_id_honoree_individual, 'email', 0, 1, 4, 'User and User Admin Only', 0, 1, @primaryLocation, {localize}'{ts escape="sql"}Email Address{/ts}'{/localize}, 'Individual');
UPDATE civicrm_uf_join SET uf_group_id = @uf_group_id_honoree_individual WHERE module = 'soft_credit';
{if $multilingual}
{foreach from=$locales item=loc}
ALTER TABLE civicrm_contribution_page DROP honor_block_title_{$loc};
ALTER TABLE civicrm_contribution_page DROP honor_block_text_{$loc};
{/foreach}
{else}
ALTER TABLE civicrm_contribution_page DROP honor_block_title;
ALTER TABLE civicrm_contribution_page DROP honor_block_text;
{/if}
ALTER TABLE civicrm_contribution_page DROP honor_block_is_active;
ALTER TABLE civicrm_contribution DROP FOREIGN KEY `FK_civicrm_contribution_honor_contact_id`;
ALTER TABLE civicrm_contribution DROP honor_contact_id;
ALTER TABLE civicrm_contribution DROP honor_type_id;
ALTER TABLE civicrm_pledge DROP FOREIGN KEY `FK_civicrm_pledge_honor_contact_id`;
ALTER TABLE civicrm_pledge DROP honor_contact_id;
ALTER TABLE civicrm_pledge DROP honor_type_id;
-- CRM-13964 and CRM-13965
SELECT @option_group_id_cs := max(id) from civicrm_option_group where name = 'contribution_status';
SELECT @option_val_id_cs_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
SELECT @option_val_id_cs_val := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cs;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cs, {localize}'{ts escape="sql"}Partially paid{/ts}'{/localize}, @option_val_id_cs_val+1, 'Partially paid', NULL, 0, NULL, @option_val_id_cs_wt+1, 0, 1, 1, NULL, NULL),
(@option_group_id_cs, {localize}'{ts escape="sql"}Pending refund{/ts}'{/localize}, @option_val_id_cs_val+2, 'Pending refund', NULL, 0, NULL, @option_val_id_cs_wt+2, 0, 1, 1, NULL, NULL);
-- participant status adding
SELECT @participant_status_wt := max(id) from civicrm_participant_status_type;
INSERT INTO civicrm_participant_status_type (name, {localize field='label'}label{/localize}, class, is_reserved, is_active, is_counted, weight, visibility_id)
VALUES
('Partially paid', {localize}'{ts escape="sql"}Partially paid{/ts}'{/localize}, 'Positive', 1, 1, 1, @participant_status_wt+1, 2),
('Pending refund', {localize}'{ts escape="sql"}Pending refund{/ts}'{/localize}, 'Positive', 1, 1, 1, @participant_status_wt+2, 2);
-- new activity types required for partial payments
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_act_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @option_group_id_act_val := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_act, {localize}'{ts escape="sql"}Payment{/ts}'{/localize}, @option_group_id_act_val+1, 'Payment', NULL, 1, NULL, @option_group_id_act_wt+1, {localize}'{ts escape="sql"}Additional payment recorded for event or membership fee.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, {localize}'{ts escape="sql"}Refund{/ts}'{/localize}, @option_group_id_act_val+2, 'Refund', NULL, 1, NULL, @option_group_id_act_wt+2, {localize}'{ts escape="sql"}Refund recorded for event or membership fee.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, {localize}'{ts escape="sql"}Change Registration{/ts}'{/localize}, @option_group_id_act_val+3, 'Change Registration', NULL, 1, NULL, @option_group_id_act_wt+3, {localize}'{ts escape="sql"}Changes to an existing event registration.{/ts}'{/localize}, 0, 1, 1, @eventCompId, NULL);
-- CRM-13970
UPDATE civicrm_navigation set url = 'civicrm/admin/options/from_email_address&reset=1' WHERE url LIKE 'civicrm/admin/options/from_email%';
UPDATE civicrm_navigation set url = CONCAT(SUBSTRING_INDEX(url, '&', 1), '&reset=1') WHERE url LIKE 'civicrm/admin/options/%';
-- CRM-14181
ALTER TABLE civicrm_acl CHANGE operation operation VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'What operation does this ACL entry control?';
ALTER TABLE civicrm_campaign_group CHANGE group_type group_type VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Type of Group.';
ALTER TABLE `civicrm_acl_contact_cache` CHANGE `operation` `operation` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'What operation does this user have permission on?';
ALTER TABLE `civicrm_price_field` CHANGE `html_type` `html_type` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `civicrm_pledge` CHANGE `frequency_unit` `frequency_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'month' COMMENT 'Time units for recurrence of pledge payments.';
ALTER TABLE `civicrm_membership_type` CHANGE `duration_unit` `duration_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Unit in which membership period is expressed.';
ALTER TABLE `civicrm_membership_type` CHANGE `period_type` `period_type` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.';
ALTER TABLE `civicrm_membership_status` CHANGE `start_event` `start_event` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Event when this status starts.';
ALTER TABLE `civicrm_membership_status` CHANGE `start_event_adjust_unit` `start_event_adjust_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Unit used for adjusting from start_event.';
ALTER TABLE `civicrm_membership_status` CHANGE `end_event` `end_event` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Event after which this status ends.';
ALTER TABLE `civicrm_membership_status` CHANGE `end_event_adjust_unit` `end_event_adjust_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Unit used for adjusting from the ending event.';
ALTER TABLE `civicrm_mailing_job` CHANGE `status` `status` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'The state of this job';
ALTER TABLE `civicrm_mailing_group` CHANGE `group_type` `group_type` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Are the members of the group included or excluded?.';
ALTER TABLE `civicrm_mailing` CHANGE `visibility` `visibility` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'User and User Admin Only' COMMENT 'In what context(s) is the mailing contents visible (online viewing)';
ALTER TABLE `civicrm_mailing_component` CHANGE `component_type` `component_type` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Type of Component.';
ALTER TABLE `civicrm_mailing_bounce_type` CHANGE `name` `name` VARCHAR( 24 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Type of bounce';
ALTER TABLE `civicrm_participant_status_type` CHANGE `class` `class` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'the general group of status type this one belongs to';
ALTER TABLE `civicrm_dedupe_rule_group` CHANGE `contact_type` `contact_type` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'The type of contacts this group applies to';
ALTER TABLE `civicrm_dedupe_rule_group` CHANGE `used` `used` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Whether the rule should be used for cases where usage is Unsupervised, Supervised OR General(programatically)';
ALTER TABLE `civicrm_word_replacement` CHANGE `match_type` `match_type` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'wildcardMatch';
ALTER TABLE `civicrm_uf_field` CHANGE `visibility` `visibility` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'User and User Admin Only' COMMENT 'In what context(s) is this field visible.';
ALTER TABLE `civicrm_mapping_field` CHANGE `operator` `operator` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'SQL WHERE operator for search-builder mapping fields (search criteria).';
ALTER TABLE `civicrm_job` CHANGE `run_frequency` `run_frequency` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'Daily' COMMENT 'Scheduled job run frequency.';
ALTER TABLE `civicrm_extension` CHANGE `type` `type` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `civicrm_custom_group` CHANGE `style` `style` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Visual relationship between this form and its parent.';
ALTER TABLE `civicrm_custom_field` CHANGE `data_type` `data_type` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Controls location of data storage in extended_data table.';
ALTER TABLE `civicrm_custom_field` CHANGE `html_type` `html_type` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'HTML types plus several built-in extended types.';
ALTER TABLE `civicrm_action_schedule` CHANGE `start_action_unit` `start_action_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Time units for reminder.';
ALTER TABLE `civicrm_action_schedule` CHANGE `repetition_frequency_unit` `repetition_frequency_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Time units for repetition of reminder.';
ALTER TABLE `civicrm_action_schedule` CHANGE `end_frequency_unit` `end_frequency_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Time units till repetition of reminder.';
ALTER TABLE `civicrm_product` CHANGE `period_type` `period_type` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'rolling' COMMENT 'Rolling means we set start/end based on current day, fixed means we set start/end for current year or month(e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) ';
ALTER TABLE `civicrm_product` CHANGE `duration_unit` `duration_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'year';
ALTER TABLE `civicrm_product` CHANGE `frequency_unit` `frequency_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'month' COMMENT 'Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.';
ALTER TABLE `civicrm_contribution_recur` CHANGE `frequency_unit` `frequency_unit` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'month' COMMENT 'Time units for recurrence of payment.';
ALTER TABLE `civicrm_subscription_history` CHANGE `method` `method` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'How the (un)subscription was triggered';
ALTER TABLE `civicrm_subscription_history` CHANGE `status` `status` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'The state of the contact within the group';
ALTER TABLE `civicrm_relationship_type` CHANGE `contact_type_a` `contact_type_a` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'If defined, contact_a in a relationship of this type must be a specific contact_type.';
ALTER TABLE `civicrm_relationship_type` CHANGE `contact_type_b` `contact_type_b` VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'If defined, contact_b in a relationship of this type must be a specific contact_type.';
ALTER TABLE `civicrm_group_contact` CHANGE `status` `status` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'status of contact relative to membership in group';
ALTER TABLE `civicrm_group` CHANGE `visibility` `visibility` VARCHAR( 24 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'User and User Admin Only' COMMENT 'In what context(s) is this field visible.';
ALTER TABLE `civicrm_contact` CHANGE `preferred_mail_format` `preferred_mail_format` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT 'Both' COMMENT 'What is the preferred mode of sending an email.';
-- CRM-14183
INSERT IGNORE INTO civicrm_state_province (country_id, abbreviation, name) VALUES (1157, "PL", "Plateau");
UPDATE civicrm_state_province SET name = "Abuja Federal Capital Territory" WHERE name = "Abuja Capital Territory";
-- CRM-13992
ALTER TABLE `civicrm_custom_field`
ADD COLUMN `in_selector` tinyint(4) DEFAULT '0' COMMENT 'Should the multi-record custom field values be displayed in tab table listing';
UPDATE civicrm_custom_field cf
LEFT JOIN civicrm_custom_group cg
ON cf.custom_group_id = cg.id
SET cf.in_selector = 1
WHERE cg.is_multiple = 1 AND cf.html_type != 'TextArea';
ALTER TABLE `civicrm_custom_group`
CHANGE COLUMN `style` `style` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Visual relationship between this form and its parent.';
-- Add "developer" help menu
SELECT @parent_id := `id` FROM `civicrm_navigation` WHERE `name` = 'Help' AND `domain_id` = {$domainID};
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, NULL, '{ts escape="sql" skip="true"}Developer{/ts}', 'Developer', 'administer CiviCRM', '', @parent_id, '1', NULL, 5 );
SET @devellastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/api', '{ts escape="sql" skip="true"}API Explorer{/ts}','API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
( {$domainID}, 'http://wiki.civicrm.org/confluence/display/CRMDOC/Develop', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );
-- CRM-14435
ALTER TABLE `civicrm_mail_settings`
ADD CONSTRAINT `FK_civicrm_mail_settings_domain_id` FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain` (`id`) ON DELETE CASCADE;
-- CRM-14436
ALTER TABLE `civicrm_mailing`
ADD COLUMN `hash` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Key for validating requests related to this mailing.',
ADD INDEX `index_hash` (`hash`);
-- CRM-14300
UPDATE `civicrm_event` SET is_template = 0 WHERE is_template IS NULL;
ALTER TABLE `civicrm_event`
CHANGE is_template is_template tinyint(4) DEFAULT '0' COMMENT 'whether the event has template';
-- CRM-14493
INSERT IGNORE INTO civicrm_state_province (country_id, abbreviation, name) VALUES (1085, "61", "Pieria");
-- CRM-14445
ALTER TABLE `civicrm_option_group`
ADD COLUMN `is_locked` int(1) DEFAULT 0 COMMENT 'A lock to remove the ability to add new options via the UI';
UPDATE `civicrm_option_group` SET is_locked = 1 WHERE name IN ('contribution_status','activity_contacts','advanced_search_options','auto_renew_options','contact_autocomplete_options','batch_status','batch_type','batch_mode','contact_edit_options','contact_reference_options','contact_smart_group_display','contact_view_options','financial_item_status','mapping_type','pcp_status','user_dashboard_options','tag_used_for');
-- CRM-14449
CREATE TABLE IF NOT EXISTS `civicrm_system_log` (
`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key: ID.',
`message` VARCHAR(128) NOT NULL COMMENT 'Standardized message',
`context` LONGTEXT NULL COMMENT 'JSON encoded data',
`level` VARCHAR(9) NOT NULL DEFAULT 'info' COMMENT 'error level per PSR3',
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp of when event occurred.',
`contact_id` INT(11) NULL DEFAULT NULL COMMENT 'Optional Contact ID that created the log. Not an FK as we keep this regardless',
hostname VARCHAR(128) NOT NULL COMMENT 'Optional Name of logging host',
PRIMARY KEY (`id`),
INDEX `message` (`message`),
INDEX `contact_id` (`contact_id`),
INDEX `level` (`level`)
)
COMMENT='Table that contains logs of all system events.'
COLLATE='utf8_general_ci';
-- CRM-14473 civicrm_case_type table creation and migration
CREATE TABLE IF NOT EXISTS `civicrm_case_type` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincremented type id',
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Machine name for Case Type',
{localize field='title'}title varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Natural language name for Case Type'{/localize},
{localize field='description'}description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Description of the Case Type'{/localize},
`is_active` tinyint(4) DEFAULT NULL COMMENT 'Is this entry active?',
`is_reserved` tinyint(4) DEFAULT NULL COMMENT 'Is this case type a predefined system type?',
`weight` int(11) NOT NULL DEFAULT '1' COMMENT 'Ordering of the case types',
`definition` blob COMMENT 'xml definition of case type',
PRIMARY KEY (`id`),
UNIQUE KEY `case_type_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
SELECT @option_group_id_case_type := max(id) from civicrm_option_group where name = 'case_type';
INSERT IGNORE INTO civicrm_case_type
(id, name, {localize field='title'}title{/localize}, {localize field='description'}description{/localize}, is_active, is_reserved, weight)
SELECT
value,
name,
{localize field='label'}label{/localize},
{localize field='description'}description{/localize},
is_active,
is_reserved,
weight
FROM civicrm_option_value
WHERE
option_group_id = @option_group_id_case_type;
-- Remove the special character, earlier used as a separator and reference to civicrm_case_type.id
UPDATE civicrm_case SET case_type_id = replace(case_type_id, 0x01, '');
ALTER TABLE civicrm_case
MODIFY case_type_id int(10) unsigned COLLATE utf8_unicode_ci NULL COMMENT 'FK to civicrm_case_type.id',
ADD CONSTRAINT FK_civicrm_case_case_type_id FOREIGN KEY (case_type_id) REFERENCES civicrm_case_type (id) ON DELETE SET NULL;
-- CRM-15343 set the auto increment civicrm_case_type.id start point to max id to avoid conflict in future insertion
SELECT @max_case_type_id := max(id) from civicrm_case_type;
SET @query = CONCAT("ALTER TABLE civicrm_case_type AUTO_INCREMENT = ", IFNULL(@max_case_type_id,1));
PREPARE alter_case_type_auto_inc FROM @query;
EXECUTE alter_case_type_auto_inc;
DEALLOCATE PREPARE alter_case_type_auto_inc;
DELETE FROM civicrm_option_value WHERE option_group_id = @option_group_id_case_type;
DELETE FROM civicrm_option_group WHERE id = @option_group_id_case_type;
-- CRM-14611
{if $multilingual}
{foreach from=$locales item=locale}
ALTER TABLE civicrm_survey ADD title_{$locale} varchar(255);
UPDATE civicrm_survey SET title_{$locale} = title;
ALTER TABLE civicrm_survey ADD instructions_{$locale} TEXT;
UPDATE civicrm_survey SET instructions_{$locale} = instructions;
{/foreach}
ALTER TABLE civicrm_survey DROP title;
ALTER TABLE civicrm_survey DROP instructions;
{/if}
-- CRM-11182 -- Make event confirmation page optional
ALTER TABLE civicrm_event
ADD COLUMN is_confirm_enabled tinyint(4) DEFAULT '1';
UPDATE civicrm_event
SET is_confirm_enabled = 1
WHERE is_monetary = 1;
UPDATE civicrm_event
SET is_confirm_enabled = 0
WHERE is_monetary = 0;
-- CRM-11182
ALTER TABLE civicrm_event
ADD COLUMN dedupe_rule_group_id int(10) unsigned DEFAULT NULL COMMENT 'Rule to use when matching registrations for this event',
ADD CONSTRAINT `FK_civicrm_event_dedupe_rule_group_id` FOREIGN KEY (`dedupe_rule_group_id`) REFERENCES `civicrm_dedupe_rule_group` (`id`);
-- CRM-9288
SELECT @option_web_id := id FROM civicrm_option_group WHERE name = 'website_type';
SELECT @website_default := value FROM civicrm_option_value WHERE option_group_id = @option_web_id and is_default = 1;
SELECT @website_work := value FROM civicrm_option_value WHERE option_group_id = @option_web_id and name= 'Work';
UPDATE civicrm_option_value
SET is_default = 1 WHERE option_group_id = @option_web_id and value = IFNULL(@website_default , @website_work);
SELECT @website_default := value FROM civicrm_option_value WHERE option_group_id = @option_web_id and is_default = 1;
ALTER TABLE civicrm_uf_field
ADD COLUMN `website_type_id` int(10) unsigned DEFAULT NULL COMMENT 'Website Type Id, if required' AFTER phone_type_id,
ADD INDEX `IX_website_type_id` (`website_type_id`);
UPDATE civicrm_uf_field
SET website_type_id = @website_default,
field_name = 'url' WHERE field_name LIKE 'url%';
SELECT @website_value := max(cast(value as UNSIGNED)) FROM civicrm_option_value WHERE option_group_id = @option_web_id;
SELECT @website_weight := max(weight) FROM civicrm_option_value WHERE option_group_id = @option_web_id;
INSERT INTO civicrm_option_value(option_group_id, {localize field='label'}label{/localize}, name, value, weight)
SELECT @option_web_id, {localize}website{/localize}, website, (@website_value := @website_value + 1), (@website_weight := @website_weight + 1) FROM (
SELECT 'Google+' AS website
UNION ALL
SELECT 'Instagram' AS website
UNION ALL
SELECT 'LinkedIn' AS website
UNION ALL
SELECT 'Pinterest' AS website
UNION ALL
SELECT 'Tumblr' AS website
UNION ALL
SELECT 'SnapChat' AS website
UNION ALL
SELECT 'Vine' AS website
) AS temp
LEFT JOIN civicrm_option_value co ON co.name = temp.website
AND option_group_id = @option_web_id
WHERE co.id IS NULL;
-- CRM-14627 civicrm navigation inconsistent
UPDATE civicrm_navigation
SET civicrm_navigation.url = CONCAT(SUBSTRING(url FROM 1 FOR LOCATE('&', url) - 1), '?', SUBSTRING(url FROM LOCATE('&', url) + 1))
WHERE civicrm_navigation.url LIKE "%&%" AND civicrm_navigation.url NOT LIKE "%?%";
-- CRM-14478 Add a "cleanup" policy for managed entities
ALTER TABLE `civicrm_managed`
ADD COLUMN `cleanup` varchar(32) COMMENT 'Policy on when to cleanup entity (always, never, unused)';
-- CRM-14639
SELECT @option_grant_status := id FROM civicrm_option_group WHERE name = 'grant_status';
UPDATE civicrm_option_value
SET
{if !$multilingual}
label =
CASE
WHEN lower(name) = 'granted'
THEN 'Paid'
WHEN lower(name) = 'approved'
THEN 'Eligible'
WHEN lower(name) = 'rejected'
THEN 'Ineligible'
ELSE 'Submitted'
END,
{else}
{foreach from=$locales item=locale}
label_{$locale} =
CASE
WHEN lower(name) = 'granted'
THEN 'Paid'
WHEN lower(name) = 'approved'
THEN 'Eligible'
WHEN lower(name) = 'rejected'
THEN 'Ineligible'
ELSE 'Submitted'
END,
{/foreach}
{/if}
name =
CASE
WHEN lower(name) = 'granted'
THEN 'Paid'
WHEN lower(name) = 'approved'
THEN 'Eligible'
WHEN lower(name) = 'rejected'
THEN 'Ineligible'
ELSE 'Submitted'
END
WHERE option_group_id = @option_grant_status and name IN ('granted', 'pending', 'approved', 'rejected');
SELECT @grant_value := max(cast(value as UNSIGNED)) FROM civicrm_option_value WHERE option_group_id = @option_grant_status;
SELECT @grant_weight := max(weight) FROM civicrm_option_value WHERE option_group_id = @option_grant_status;
INSERT INTO civicrm_option_value(option_group_id, {localize field='label'}label{/localize}, name, value, weight)
SELECT @option_grant_status, {localize}grantstatus{/localize}, grantstatus, @grant_value := @grant_value + 1, @grant_weight := @grant_weight + 1 FROM (
SELECT 'Submitted' AS grantstatus
UNION ALL
SELECT 'Approved for Payment' AS grantstatus
UNION ALL
SELECT 'Eligible' AS grantstatus
UNION ALL
SELECT 'Awaiting Information' AS grantstatus
UNION ALL
SELECT 'Withdrawn' AS grantstatus
) AS temp
LEFT JOIN civicrm_option_value co ON co.name = temp.grantstatus
AND option_group_id = @option_grant_status
WHERE co.id IS NULL;
-- Fix trailing single quote in grant status label
{if !$multilingual}
UPDATE civicrm_option_value v
INNER JOIN civicrm_option_group g
ON v.option_group_id = g.id AND g.name = 'grant_status'
SET label = 'Awaiting Information'
WHERE v.label = 'Awaiting Information\'' and v.name = 'Awaiting Information';
{else}
UPDATE civicrm_option_value v
INNER JOIN civicrm_option_group g
ON v.option_group_id = g.id AND g.name = 'grant_status'
SET
{foreach from=$locales item=locale}
v.label_{$locale} = CASE
WHEN v.label_{$locale} = 'Awaiting Information\'' THEN 'Awaiting Information'
ELSE v.label_{$locale}
END,
{/foreach}
v.name = v.name
WHERE v.name = 'Awaiting Information';
{/if}
-- CRM-14197 Add contribution_id to civicrm_line_item
ALTER TABLE civicrm_line_item ADD contribution_id INT(10) unsigned COMMENT 'Contribution ID' NULL AFTER entity_id;
-- FK to civicrm_contribution
ALTER TABLE civicrm_line_item
ADD CONSTRAINT `FK_civicrm_contribution_id` FOREIGN KEY (`contribution_id`) REFERENCES civicrm_contribution (`id`) ON DELETE SET NULL;
ALTER TABLE `civicrm_line_item`
DROP INDEX `UI_line_item_value`,
ADD UNIQUE INDEX `UI_line_item_value` (`entity_table`, `entity_id`, `contribution_id`, `price_field_value_id`, `price_field_id`);
-- update case type menu
UPDATE civicrm_navigation set url = 'civicrm/a/#/caseType' WHERE url LIKE 'civicrm/admin/options/case_type%';

View file

@ -0,0 +1,35 @@
UPDATE civicrm_dashboard
SET civicrm_dashboard.url = CONCAT(SUBSTRING(url FROM 1 FOR LOCATE('&', url) - 1), '?', SUBSTRING(url FROM LOCATE('&', url) + 1))
WHERE civicrm_dashboard.url LIKE "%&%" AND civicrm_dashboard.url NOT LIKE "%?%";
UPDATE civicrm_dashboard
SET civicrm_dashboard.fullscreen_url = CONCAT(SUBSTRING(fullscreen_url FROM 1 FOR LOCATE('&', fullscreen_url) - 1), '?', SUBSTRING(fullscreen_url FROM LOCATE('&', fullscreen_url) + 1))
WHERE civicrm_dashboard.fullscreen_url LIKE "%&%" AND civicrm_dashboard.fullscreen_url NOT LIKE "%?%";
-- CRM-14843 Added States for Chile and Modify Santiago Metropolitan for consistency
INSERT IGNORE INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
(NULL, 1044, "LR", "Los Rios"),
(NULL, 1044, "AP", "Arica y Parinacota"),
(NULL, 1169, "AMA", "Amazonas");
UPDATE civicrm_state_province
SET name = "Santiago Metropolitan", abbreviation = "SM"
WHERE name = "Region Metropolitana de Santiago" AND abbreviation = "RM";
-- CRM-14879 contact fields for scheduled reminders
INSERT INTO civicrm_action_mapping
(entity, entity_value, entity_value_label, entity_status, entity_status_label, entity_date_start, entity_date_end, entity_recipient)
VALUES
( 'civicrm_contact', 'civicrm_contact', 'Date Field', 'contact_date_reminder_options', 'Annual Options', 'date_field', NULL, NULL);
INSERT INTO `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`, `is_locked`)
VALUES
('contact_date_reminder_options', {localize}'{ts escape="sql"}Contact Date Reminder Options{/ts}'{/localize}, 1, 1, 1);
SELECT @option_group_id_contactDateMode := max(id) from civicrm_option_group where name = 'contact_date_reminder_options';
INSERT INTO `civicrm_option_value`
(`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_contactDateMode, {localize}'{ts escape="sql"}Actual date only{/ts}'{/localize}, '1', 'Actual date only', NULL, NULL, 0, 1, 0, 1, 1, NULL, NULL),
(@option_group_id_contactDateMode, {localize}'{ts escape="sql"}Each anniversary{/ts}'{/localize}, '2', 'Each anniversary', NULL, NULL, 0, 2, 0, 1, 1, NULL, NULL);

View file

@ -0,0 +1,6 @@
{* file to handle db changes in 4.5.beta1 during upgrade *}
-- CRM-14807
ALTER TABLE `civicrm_action_schedule`
ADD COLUMN `from_name` varchar(255) AFTER `absolute_date`;
ALTER TABLE `civicrm_action_schedule`
ADD COLUMN `from_email` varchar(255) AFTER `from_name`;

View file

@ -0,0 +1,13 @@
{* file to handle db changes in 4.5.beta2 during upgrade *}
{include file='../CRM/Upgrade/4.5.beta2.msg_template/civicrm_msg_template.tpl'}
--CRM-14948 To delete list of outdated Russian provinance
DELETE FROM `civicrm_state_province` WHERE `name` IN ('Komi-Permyatskiy avtonomnyy okrug','Taymyrskiy (Dolgano-Nenetskiy)','Evenkiyskiy avtonomnyy okrug','Koryakskiy avtonomnyy okrug','Ust\'-Ordynskiy Buryatskiy','Aginskiy Buryatskiy avtonomnyy');
--CRM-14948 To update new list of new Russian provinance
UPDATE `civicrm_state_province` SET `name`='Perm krai',`abbreviation`='PEK',`country_id`= 1177 WHERE `id` = 4270;
UPDATE `civicrm_state_province` SET `name`='Kamchatka Krai',`country_id`= 1177 WHERE `id` = 4252;
UPDATE `civicrm_state_province` SET `name`='Zabaykalsky Krai',`abbreviation`='ZSK',`country_id`= 1177 WHERE `id` = 4247;

View file

@ -0,0 +1,4 @@
{* file to handle db changes in 4.5.beta3 during upgrade *}
--CRM-15009
ALTER TABLE `civicrm_payment_processor`
CHANGE COLUMN `signature` `signature` LONGTEXT NULL DEFAULT NULL;

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.beta4 during upgrade *}

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.beta5 during upgrade *}

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.5.beta6 during upgrade *}

View file

@ -0,0 +1,2 @@
{* file to handle db changes in 4.5.beta7 during upgrade *}
UPDATE civicrm_contribution SET net_amount = total_amount - fee_amount WHERE net_amount = 0 OR net_amount IS NULL;

View file

@ -0,0 +1,18 @@
{* file to handle db changes in 4.5.beta8 during upgrade *}
-- CRM-15143 Add Postal Code to contact reference and quick search options
SELECT @option_group_id_cao := max(id) from civicrm_option_group where name = 'contact_autocomplete_options';
SELECT @option_val_id_cao_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cao;
SELECT @option_val_id_cao_val := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cao;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cao, {localize}'{ts escape="sql"}Postal Code{/ts}'{/localize}, @option_val_id_cao_val+1, 'postal_code', NULL, 0, NULL, @option_val_id_cao_wt+1, 0, 1, 1, NULL, NULL);
SELECT @option_group_id_cro := max(id) from civicrm_option_group where name = 'contact_reference_options';
SELECT @option_val_id_cro_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cro;
SELECT @option_val_id_cro_val := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_cro;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_cro, {localize}'{ts escape="sql"}Postal Code{/ts}'{/localize}, @option_val_id_cro_val+1, 'postal_code', NULL, 0, NULL, @option_val_id_cro_wt+1, 0, 1, 1, NULL, NULL);

View file

@ -0,0 +1,36 @@
{* file to handle db changes in 4.5.beta9 during upgrade *}
-- CRM-15211
UPDATE `civicrm_dashboard` SET `permission` = 'access my cases and activities,access all cases and activities', `permission_operator` = 'OR' WHERE `name` = 'casedashboard';
-- CRM-15218
UPDATE `civicrm_uf_group` SET name = LOWER(name) WHERE name IN ("New_Individual", "New_Organization", "New_Household");
-- CRM-15220
UPDATE `civicrm_navigation` SET url = 'civicrm/admin/options/grant_type?reset=1' WHERE url = 'civicrm/admin/options/grant_type&reset=1';
SELECT @parent_id := `id` FROM `civicrm_navigation` WHERE `name` = 'CiviGrant' AND `domain_id` = {$domainID};
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/admin/options/grant_status?reset=1', '{ts escape="sql" skip="true"}Grant Status{/ts}', 'Grant Status', 'access CiviGrant,administer CiviCRM', 'AND', @parent_id, '1', NULL, 2 );
-- CRM-14853
UPDATE civicrm_financial_trxn cft
INNER JOIN ( SELECT max(cft.id) trxn_id, ceft.entity_id contribution_id
FROM civicrm_financial_trxn cft
LEFT JOIN civicrm_entity_financial_trxn ceft ON ceft.financial_trxn_id = cft.id
WHERE ceft.entity_table = 'civicrm_contribution'
GROUP BY ceft.entity_id ) as temp ON temp.trxn_id = cft.id
INNER JOIN civicrm_contribution cc ON cc.id = temp.contribution_id
AND cc.payment_instrument_id <> cft.payment_instrument_id
SET cft.payment_instrument_id = cc.payment_instrument_id;
--CRM-15086
SELECT @option_group_id_batch_status := id FROM civicrm_option_group WHERE name = 'batch_status';
UPDATE civicrm_option_value SET name = 'Open' WHERE value = 1 AND option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value SET name = 'Closed' WHERE value = 2 AND option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value SET name = 'Data Entry' WHERE value = 3 AND option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value SET name = 'Reopened' WHERE value = 4 AND option_group_id = @option_group_id_batch_status;
UPDATE civicrm_option_value SET name = 'Exported' WHERE value = 5 AND option_group_id = @option_group_id_batch_status;

View file

@ -0,0 +1,46 @@
{* file to handle db changes in 4.6.0 during upgrade *}
--CRM-16148 add missing option names
SELECT @option_group_id_pcm := max(id) from civicrm_option_group where name = 'preferred_communication_method';
SELECT @option_group_id_notePrivacy := max(id) from civicrm_option_group where name = 'note_privacy';
UPDATE civicrm_option_value
SET name = 'Phone'
WHERE option_group_id = @option_group_id_pcm AND value = 1;
UPDATE civicrm_option_value
SET name = 'Email'
WHERE option_group_id = @option_group_id_pcm AND value = 2;
UPDATE civicrm_option_value
SET name = 'Postal Mail'
WHERE option_group_id = @option_group_id_pcm AND value = 3;
UPDATE civicrm_option_value
SET name = 'SMS'
WHERE option_group_id = @option_group_id_pcm AND value = 4;
UPDATE civicrm_option_value
SET name = 'Fax'
WHERE option_group_id = @option_group_id_pcm AND value = 5;
UPDATE civicrm_option_value
SET name = 'None'
WHERE option_group_id = @option_group_id_notePrivacy AND value = 0;
UPDATE civicrm_option_value
SET name = 'Author Only'
WHERE option_group_id = @option_group_id_notePrivacy AND value = 1;
--These labels were never translated so just copy them over as names
{if $multilingual}
UPDATE civicrm_option_value v, civicrm_option_group g
SET v.name = v.label_{$locales.0}
WHERE g.id = v.option_group_id AND g.name IN
('group_type', 'safe_file_extension', 'wysiwyg_editor');
{else}
UPDATE civicrm_option_value v, civicrm_option_group g
SET v.name = v.label
WHERE g.id = v.option_group_id AND g.name IN
('group_type', 'safe_file_extension', 'wysiwyg_editor');
{/if}
--This one is weird. What the heck is this anyway?
UPDATE civicrm_option_value v, civicrm_option_group g
SET v.name = v.value
WHERE g.id = v.option_group_id AND g.name = 'redaction_rule';

View file

@ -0,0 +1 @@
{* CRM-16846 - This file is never run, but it doesn't matter because it's empty *}

View file

@ -0,0 +1,13 @@
{* file to handle db changes in 4.6.10 during upgrade *}
-- CRM-17384 - remove duplicate support menu which may have been added in 4.6.9
DELETE n1
FROM civicrm_navigation n1, civicrm_navigation n2
WHERE n1.name = 'Support' AND n1.domain_id = {$domainID} AND n2.name = 'Support' AND n2.domain_id = {$domainID} AND n1.id < n2.id;
-- CRM-17384 - re-add sid in case the site admin deleted the new support menu after upgrading to 4.6.9
UPDATE civicrm_navigation SET url = 'https://civicrm.org/register-your-site?src=iam&sid={ldelim}sid{rdelim}' WHERE name = 'Register your site';
UPDATE civicrm_navigation SET url = 'https://civicrm.org/become-a-member?src=iam&sid={ldelim}sid{rdelim}' WHERE name = 'Join CiviCRM';
--CRM-17357 PHP fatal error during creation of receipt PDF
{include file='../CRM/Upgrade/4.6.10.msg_template/civicrm_msg_template.tpl'}

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.6.11 during upgrade *}

View file

@ -0,0 +1,13 @@
{* file to handle db changes in 4.6.12 during upgrade *}
-- CRM-16173, CRM-16831
SELECT @parent_id := id from `civicrm_navigation` where name = 'System Settings' AND domain_id = {$domainID};
SELECT @add_weight_id := weight from `civicrm_navigation` where `name` = 'Manage Extensions' and `parent_id` = @parent_id;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+1
WHERE `parent_id` = @parent_id
AND `weight` > @add_weight_id;
INSERT INTO `civicrm_navigation`
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/a/#/cxn', '{ts escape="sql" skip="true"}Connections{/ts}', 'Connections', 'administer CiviCRM', '', @parent_id , '1', NULL, @add_weight_id + 1 );

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.6.2 during upgrade *}

View file

@ -0,0 +1,73 @@
{* file to handle db changes in 4.6.3 during upgrade *}
-- CRM-16307 fix CRM-15578 typo - Require access CiviMail permission for A/B Testing feature
UPDATE civicrm_navigation
SET permission = 'access CiviMail', permission_operator = ''
WHERE name = 'New A/B Test' OR name = 'Manage A/B Tests';
--CRM-16320
{include file='../CRM/Upgrade/4.6.3.msg_template/civicrm_msg_template.tpl'}
-- CRM-16452 Missing administrative divisions for Georgia
SELECT @country_id := id from civicrm_country where name = 'Georgia' AND iso_code = 'GE';
INSERT INTO civicrm_state_province (country_id, abbreviation, name)
VALUES
(@country_id, "AB", "Abkhazia"),
(@country_id, "AJ", "Adjara"),
(@country_id, "TB", "Tbilisi"),
(@country_id, "GU", "Guria"),
(@country_id, "IM", "Imereti"),
(@country_id, "KA", "Kakheti"),
(@country_id, "KK", "Kvemo Kartli"),
(@country_id, "MM", "Mtskheta-Mtianeti"),
(@country_id, "RL", "Racha-Lechkhumi and Kvemo Svaneti"),
(@country_id, "SZ", "Samegrelo-Zemo Svaneti"),
(@country_id, "SJ", "Samtskhe-Javakheti"),
(@country_id, "SK", "Shida Kartli");
--CRM-16391 and CRM-16392
UPDATE civicrm_uf_field
SET {localize field="label"}label = '{ts escape="sql"}Financial Type{/ts}'{/localize}
WHERE field_type = 'Contribution' AND field_name='financial_type';
UPDATE civicrm_uf_field
SET {localize field="label"}label = '{ts escape="sql"}Membership Type{/ts}'{/localize}
WHERE field_type = 'Membership' AND field_name='membership_type';
-- CRM-16367: adding the shared payment token table
CREATE TABLE IF NOT EXISTS `civicrm_payment_token` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Payment Token ID',
`contact_id` int unsigned NOT NULL COMMENT 'FK to Contact ID for the owner of the token',
`payment_processor_id` int unsigned NOT NULL ,
`token` varchar(255) NOT NULL COMMENT 'Externally provided token string',
`created_date` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'Date created',
`created_id` int unsigned COMMENT 'Contact ID of token creator',
`expiry_date` datetime COMMENT 'Date this token expires',
`email` varchar(255) COMMENT 'Email at the time of token creation. Useful for fraud forensics',
`billing_first_name` varchar(255) COMMENT 'Billing first name at the time of token creation. Useful for fraud forensics',
`billing_middle_name` varchar(255) COMMENT 'Billing middle name at the time of token creation. Useful for fraud forensics',
`billing_last_name` varchar(255) COMMENT 'Billing last name at the time of token creation. Useful for fraud forensics',
`masked_account_number` varchar(255) COMMENT 'Holds the part of the card number or account details that may be retained or displayed',
`ip_address` varchar(255) COMMENT 'IP used when creating the token. Useful for fraud forensics' ,
PRIMARY KEY ( `id` ),
CONSTRAINT FK_civicrm_payment_token_contact_id FOREIGN KEY (`contact_id`)
REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE,
CONSTRAINT FK_civicrm_payment_token_payment_processor_id FOREIGN KEY (`payment_processor_id`)
REFERENCES `civicrm_payment_processor`(`id`) ON DELETE RESTRICT,
CONSTRAINT FK_civicrm_payment_token_created_id FOREIGN KEY (`created_id`)
REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL
)
ENGINE=InnoDB DEFAULT
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
-- CRM-16367: adding a reference to the token table to the recurring contributions table.
ALTER TABLE civicrm_contribution_recur
ADD COLUMN `payment_token_id` int(10) unsigned DEFAULT NULL COMMENT 'Optionally used to store a link to a payment token used for this recurring contribution.',
ADD CONSTRAINT `FK_civicrm_contribution_recur_payment_token_id` FOREIGN KEY (`payment_token_id`) REFERENCES `civicrm_payment_token` (`id`) ON DELETE SET NULL;
--CRM-16480: set total_amount and financial_type fields 'is_required' to null
SELECT @uf_group_id_contribution := max(id) from civicrm_uf_group where name = 'contribution_batch_entry';
SELECT @uf_group_id_membership := max(id) from civicrm_uf_group where name = 'membership_batch_entry';
UPDATE civicrm_uf_field
SET is_required = 0 WHERE uf_group_id IN (@uf_group_id_contribution, @uf_group_id_membership) AND field_name IN ('financial_type', 'total_amount');

View file

@ -0,0 +1,2 @@
{* file to handle db changes in 4.6.4 during upgrade *}
UPDATE civicrm_uf_group SET group_type = 'Contact,Organization' WHERE civicrm_uf_group.name = 'on_behalf_organization' AND group_type <> 'Contact,Organization';

View file

@ -0,0 +1,35 @@
{* file to handle db changes in 4.6.5 during upgrade *}
-- CRM-16173
CREATE TABLE IF NOT EXISTS `civicrm_cxn` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Connection ID',
`app_guid` varchar(128) COMMENT 'Application GUID',
`app_meta` text COMMENT 'Application Metadata (JSON)',
`cxn_guid` varchar(128) COMMENT 'Connection GUID',
`secret` text COMMENT 'Shared secret',
`perm` text COMMENT 'Permissions approved for the service (JSON)',
`options` text COMMENT 'Options for the service (JSON)',
`is_active` tinyint DEFAULT 1 COMMENT 'Is connection currently enabled?',
`created_date` timestamp NULL DEFAULT NULL COMMENT 'When was the connection was created.',
`modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the connection was created or modified.',
`fetched_date` timestamp NULL DEFAULT NULL COMMENT 'The last time the application metadata was fetched.' ,
PRIMARY KEY ( `id` )
, UNIQUE INDEX `UI_appid`(
app_guid
)
, UNIQUE INDEX `UI_keypair_cxnid`(
cxn_guid
)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
-- CRM-16417 add failed payment activity type
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_act_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @option_group_id_act_val := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute';
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_act, {localize}'{ts escape="sql"}Failed Payment{/ts}'{/localize}, @option_group_id_act_val+1,
'Failed Payment', NULL, 1, NULL, @option_group_id_act_wt+1, {localize}'{ts escape="sql"}Failed payment.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL);

View file

@ -0,0 +1,11 @@
{* file to handle db changes in 4.6.6 during upgrade *}
-- CRM-16846 - This upgrade may have been previously skipped so moving it to 4.6.6
-- update permission for editing message templates (CRM-15819)
SELECT @messages_menu_id := id FROM civicrm_navigation WHERE name = 'Mailings';
UPDATE `civicrm_navigation`
SET `permission` = 'edit message templates'
WHERE `parent_id` = @messages_menu_id
AND name = 'Message Templates';

View file

@ -0,0 +1,5 @@
{* file to handle db changes in 4.6.7 during upgrade *}
-- CRM-17016 State list for Fiji incomplete
SELECT @country_id := id from civicrm_country where name = 'Fiji' AND iso_code = 'FJ';
INSERT INTO civicrm_state_province (country_id, abbreviation, name) VALUES (@country_id, "C", "Central");

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.6.8 during upgrade *}

View file

@ -0,0 +1,59 @@
{* file to handle db changes in 4.6.9 during upgrade *}
-- CRM-17112 - Add Missing countries Saint Barthélemy and Saint Martin
INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Saint Barthélemy", "BL", "2", "0");
INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Saint Martin (French part)", "MF", "2", "0");
-- CRM-17039 - Add credit note for cancelled payments
{include file='../CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl'}
-- CRM-17258 - Add created id, owner_id to report instances.
ALTER TABLE civicrm_report_instance
ADD COLUMN `created_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to contact table.',
ADD COLUMN `owner_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to contact table.',
ADD CONSTRAINT `FK_civicrm_report_instance_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL,
ADD CONSTRAINT `FK_civicrm_report_instance_owner_id` FOREIGN KEY (`owner_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL;
-- CRM-16907
SELECT @navMaxWeight := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id IS NULL;
-- Add "support" menu if it's not there already
INSERT INTO civicrm_navigation (domain_id, label, name, is_active, weight)
SELECT * FROM (SELECT {$domainID} as domain_id, 'Support' as label, 'Help' as name, 1 as is_active, @navMaxWeight + 1 as weight) AS tmp
WHERE NOT EXISTS (
SELECT name FROM civicrm_navigation WHERE name = 'Help' AND domain_id = {$domainID}
) LIMIT 1;
SELECT @adminHelplastID := id FROM civicrm_navigation WHERE name = 'Help' AND domain_id = {$domainID};
UPDATE civicrm_navigation
SET name = 'Support', label = '{ts escape="sql" skip="true"}Support{/ts}'
WHERE id = @adminHelplastID;
DELETE FROM civicrm_navigation where parent_id = @adminHelplastID AND (name = 'Developer' OR url LIKE "http://civicrm.org%");
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'https://civicrm.org/get-started?src=iam', '{ts escape="sql" skip="true"}Get started{/ts}', 'Get started', NULL, 'AND', @adminHelplastID, '1', NULL, 1 ),
( {$domainID}, 'https://civicrm.org/documentation?src=iam', '{ts escape="sql" skip="true"}Documentation{/ts}', 'Documentation', NULL, 'AND', @adminHelplastID, '1', NULL, 2 ),
( {$domainID}, 'https://civicrm.org/ask-a-question?src=iam', '{ts escape="sql" skip="true"}Ask a question{/ts}', 'Ask a question', NULL, 'AND', @adminHelplastID, '1', NULL, 3 ),
( {$domainID}, 'https://civicrm.org/experts?src=iam', '{ts escape="sql" skip="true"}Get expert help{/ts}', 'Get expert help', NULL, 'AND', @adminHelplastID, '1', NULL, 4 ),
( {$domainID}, 'https://civicrm.org/about?src=iam', '{ts escape="sql" skip="true"}About CiviCRM{/ts}', 'About CiviCRM', NULL, 'AND', @adminHelplastID, '1', 1, 5 ),
( {$domainID}, 'https://civicrm.org/register-your-site?src=iam&sid={ldelim}sid{rdelim}', '{ts escape="sql" skip="true"}Register your site{/ts}', 'Register your site', NULL, 'AND', @adminHelplastID, '1', NULL, 6 ),
( {$domainID}, 'https://civicrm.org/become-a-member?src=iam&sid={ldelim}sid{rdelim}', '{ts escape="sql" skip="true"}Join CiviCRM{/ts}', 'Join CiviCRM', NULL, 'AND', @adminHelplastID, '1', NULL, 7 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, NULL, '{ts escape="sql" skip="true"}Developer{/ts}', 'Developer', 'administer CiviCRM', '', @adminHelplastID, '1', 1, 8 );
SET @devellastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/api', '{ts escape="sql" skip="true"}API Explorer{/ts}','API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
( {$domainID}, 'https://civicrm.org/developer-documentation?src=iam', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );
-- Set CiviCRM URLs to https
UPDATE civicrm_navigation SET url = REPLACE(url, 'http://civicrm.org', 'https://civicrm.org');

View file

@ -0,0 +1,155 @@
{* file to handle db changes in 4.6.alpha1 during upgrade *}
{include file='../CRM/Upgrade/4.6.alpha1.msg_template/civicrm_msg_template.tpl'}
-- Financial account relationship
SELECT @option_group_id_arel := max(id) from civicrm_option_group where name = 'account_relationship';
SELECT @option_group_id_arel_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel;
SELECT @option_group_id_arel_val := MAX(CAST( `value` AS UNSIGNED )) FROM civicrm_option_value WHERE option_group_id = @option_group_id_arel;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_arel, {localize}'{ts escape="sql"}Sales Tax Account is{/ts}'{/localize}, @option_group_id_arel_val+1, 'Sales Tax Account is', NULL, 0, 0, @option_group_id_arel_wt+1, {localize}'Sales Tax Account is'{/localize}, 0, 1, 1, 2, NULL);
-- Add new column tax_amount in contribution and lineitem table
ALTER TABLE `civicrm_contribution` ADD `tax_amount` DECIMAL( 20, 2 ) DEFAULT NULL COMMENT 'Total tax amount of this contribution.';
ALTER TABLE `civicrm_line_item` ADD `tax_amount` DECIMAL( 20, 2 ) DEFAULT NULL COMMENT 'tax of each item';
-- Insert menu item at Administer > CiviContribute, below the Payment Processors.
SELECT @parent_id := id from `civicrm_navigation` where name = 'CiviContribute' AND domain_id = {$domainID};
SELECT @add_weight_id := weight from `civicrm_navigation` where `name` = 'Payment Processors' and `parent_id` = @parent_id;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+1
WHERE `parent_id` = @parent_id
AND `weight` > @add_weight_id;
INSERT INTO `civicrm_navigation`
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/admin/setting/preferences/contribute', '{ts escape="sql" skip="true"}CiviContribute Component Settings{/ts}', 'CiviContribute Component Settings', 'administer CiviCRM', '', @parent_id, '1', NULL, @add_weight_id + 1 );
CREATE TABLE IF NOT EXISTS `civicrm_mailing_abtest` (
`id` int unsigned NOT NULL AUTO_INCREMENT ,
`name` varchar(128) COMMENT 'Name of the A/B test',
`status` varchar(32) COMMENT 'Status',
`mailing_id_a` int unsigned COMMENT 'The first experimental mailing (\"A\" condition)',
`mailing_id_b` int unsigned COMMENT 'The second experimental mailing (\"B\" condition)',
`mailing_id_c` int unsigned COMMENT 'The final, general mailing (derived from A or B)',
`domain_id` int unsigned COMMENT 'Which site is this mailing for',
`testing_criteria_id` int unsigned ,
`winner_criteria_id` int unsigned ,
`specific_url` varchar(255) COMMENT 'What specific url to track',
`declare_winning_time` datetime COMMENT 'In how much time to declare winner',
`group_percentage` int unsigned
,
PRIMARY KEY ( `id` )
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
-- Insert menu items under "Mailings" for A/B Tests
SELECT @parent_id := id from `civicrm_navigation` where name = 'Mailings' AND domain_id = {$domainID};
SELECT @add_weight_id := weight from `civicrm_navigation` where `name` = 'Find Mass SMS' and `parent_id` = @parent_id;
UPDATE `civicrm_navigation`
SET `weight` = `weight`+2
WHERE `parent_id` = @parent_id
AND `weight` > @add_weight_id;
INSERT INTO `civicrm_navigation`
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( {$domainID}, 'civicrm/a/#/abtest/new', '{ts escape="sql" skip="true"}New A/B Test{/ts}', 'New A/B Test', 'access CiviMail,create mailings', 'OR', @parent_id , '1', NULL, @add_weight_id + 1 ),
( {$domainID}, 'civicrm/a/#/abtest', '{ts escape="sql" skip="true"}Manage A/B Tests{/ts}', 'Manage A/B Tests', 'access CiviMail,create mailings', 'OR', @parent_id, '1', 1, @add_weight_id + 2 );
-- New activity types required for Print and Email Invoice
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_act_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
SELECT @option_group_id_act_val := MAX(CAST( `value` AS UNSIGNED )) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_act, {localize}'{ts escape="sql"}Downloaded Invoice{/ts}'{/localize}, @option_group_id_act_val+1, 'Downloaded Invoice', NULL, 1, NULL, @option_group_id_act_wt+1, {localize}'{ts escape="sql"}Downloaded Invoice.{/ts}'{/localize}, 0, 1, 1, NULL, NULL),
(@option_group_id_act, {localize}'{ts escape="sql"}Emailed Invoice{/ts}'{/localize}, @option_group_id_act_val+2, 'Emailed Invoice', NULL, 1, NULL, @option_group_id_act_wt+2, {localize}'{ts escape="sql"}Emailed Invoice.{/ts}'{/localize}, 0, 1, 1, NULL, NULL);
-- New option for Contact Dashboard
SELECT @option_group_id_udOpt := max(id) from civicrm_option_group where name = 'user_dashboard_options';
SELECT @option_group_id_udOpt_wt := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_udOpt;
SELECT @option_group_id_udOpt_val := MAX(CAST( `value` AS UNSIGNED )) FROM civicrm_option_value WHERE option_group_id = @option_group_id_udOpt;
INSERT INTO
`civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
VALUES
(@option_group_id_udOpt, {localize}'{ts escape="sql"}Invoices / Credit Notes{/ts}'{/localize}, @option_group_id_udOpt_val+1, 'Invoices / Credit Notes', NULL, 0, NULL, @option_group_id_udOpt_wt+1, 0, 0, 1, NULL, NULL);
-- Add new column creditnote_id in contribution table
ALTER TABLE `civicrm_contribution` ADD `creditnote_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'unique credit note id, system generated or passed in';
-- Add new column is_billing_required in contribution_page and event table
ALTER TABLE `civicrm_event` ADD COLUMN `is_billing_required` tinyint(4) DEFAULT '0' COMMENT 'Billing block required for Event';
ALTER TABLE `civicrm_contribution_page` ADD COLUMN `is_billing_required` tinyint(4) DEFAULT '0' COMMENT 'Billing block required for Contribution Page';
-- CRM-15256
ALTER TABLE civicrm_action_schedule ADD used_for VARCHAR(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Used for repeating entity' AFTER sms_provider_id;
CREATE TABLE IF NOT EXISTS `civicrm_recurring_entity` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`parent_id` int(10) unsigned NOT NULL COMMENT 'recurring entity parent id',
`entity_id` int(10) unsigned DEFAULT NULL COMMENT 'recurring entity child id',
`entity_table` varchar(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'physical tablename for entity, e.g. civicrm_event',
`mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1-this entity, 2-this and the following entities, 3-all the entities',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=87 ;
-- add batch type for pledge payments
SELECT @option_group_id := id FROM civicrm_option_group WHERE name = 'batch_type';
SELECT @max_option_value:= max(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id;
INSERT INTO civicrm_option_value(option_group_id, {localize field='label'}`label`{/localize}, value, name,weight)
VALUES (@option_group_id, {localize}'{ts escape="sql"}Pledge Payment{/ts}'{/localize}, @max_option_value+1, 'Pledge Payment','3');
--CRM-12281: To update name of Latvian provinces.
UPDATE `civicrm_state_province` SET `name` = (N'Jūrmala') where `id` = 3552;
UPDATE `civicrm_state_province` SET `name` = (N'Liepāja') WHERE `id` = 3553;
UPDATE `civicrm_state_province` SET `name` = (N'Rēzekne') WHERE `id` = 3554;
UPDATE `civicrm_state_province` SET `name` = (N'Rīga') WHERE `id` = 3555;
--CRM-15361: Allow selection of location type when sending bulk email
ALTER TABLE civicrm_mailing ADD COLUMN location_type_id INT(10) unsigned DEFAULT 0 COMMENT 'With email_selection_method, determines which email address to use';
ALTER TABLE civicrm_mailing ADD COLUMN email_selection_method varchar(20) DEFAULT 'automatic' COMMENT 'With location_type_id, determine how to choose the email address to use.';
-- CRM-15500 fix
ALTER TABLE `civicrm_action_schedule` CHANGE `limit_to` `limit_to` TINYINT( 4 ) NULL DEFAULT NULL;
-- CRM-15453 Recurring Contributions report template AND instance
SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
SELECT @weight := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
SELECT @contribCompId := MAX(id) FROM civicrm_component where name = 'CiviContribute';
INSERT INTO civicrm_option_value
(option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
(@option_group_id_report, {localize}'Recurring Contributions Report'{/localize}, 'contribute/recur', 'CRM_Report_Form_Contribute_Recur', @weight := @weight + 1, {localize}'Shows information about the status of recurring contributions'{/localize}, 1, @contribCompId);
INSERT INTO `civicrm_report_instance`
( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
VALUES
( {$domainID}, 'Pending Recurring Contributions', 'contribute/recur', 'Shows all pending recurring contributions', 'access CiviContribute', '{literal}a:39:{s:6:"fields";a:7:{s:9:"sort_name";s:1:"1";s:6:"amount";s:1:"1";s:22:"contribution_status_id";s:1:"1";s:18:"frequency_interval";s:1:"1";s:14:"frequency_unit";s:1:"1";s:12:"installments";s:1:"1";s:8:"end_date";s:1:"1";}s:25:"contribution_status_id_op";s:2:"in";s:28:"contribution_status_id_value";a:1:{i:0;s:1:"5";}s:11:"currency_op";s:2:"in";s:14:"currency_value";a:0:{}s:20:"financial_type_id_op";s:2:"in";s:23:"financial_type_id_value";a:0:{}s:17:"frequency_unit_op";s:2:"in";s:20:"frequency_unit_value";a:0:{}s:22:"frequency_interval_min";s:0:"";s:22:"frequency_interval_max";s:0:"";s:21:"frequency_interval_op";s:3:"lte";s:24:"frequency_interval_value";s:0:"";s:16:"installments_min";s:0:"";s:16:"installments_max";s:0:"";s:15:"installments_op";s:3:"lte";s:18:"installments_value";s:0:"";s:19:"start_date_relative";s:0:"";s:15:"start_date_from";s:0:"";s:13:"start_date_to";s:0:"";s:37:"next_sched_contribution_date_relative";s:0:"";s:33:"next_sched_contribution_date_from";s:0:"";s:31:"next_sched_contribution_date_to";s:0:"";s:17:"end_date_relative";s:0:"";s:13:"end_date_from";s:0:"";s:11:"end_date_to";s:0:"";s:28:"calculated_end_date_relative";s:0:"";s:24:"calculated_end_date_from";s:0:"";s:22:"calculated_end_date_to";s:0:"";s:9:"order_bys";a:1:{i:1;a:1:{s:6:"column";s:1:"-";}}s:11:"description";s:41:"Shows all pending recurring contributions";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:9:"row_count";s:0:"";s:14:"addToDashboard";s:1:"1";s:10:"permission";s:21:"access CiviContribute";s:9:"parent_id";s:0:"";s:11:"instance_id";N;}{/literal}');
-- CRM-15557--
ALTER TABLE civicrm_line_item MODIFY COLUMN qty decimal(20,2);
-- CRM-15740
ALTER TABLE `civicrm_mailing_trackable_url` CHANGE `url` `url` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'The URL to be tracked.';
-- CRM-15765 missing Indonesian provinces and revise outdated names
INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`)
VALUES (NULL, 1102, "SR", "Sulawesi Barat"), (NULL, 1102, "KT", "Kalimantan Tengah"), (NULL, 1102, "KU", "Kalimantan Utara");
UPDATE `civicrm_state_province` SET `name`='Kepulauan Bangka Belitung' WHERE `id` = 3056;
UPDATE `civicrm_state_province` SET `name`='Papua Barat', `abbreviation`='PB' WHERE `id` = 3060;
UPDATE `civicrm_state_province` SET `name`='DKI Jakarta' WHERE `id` = 3083;
UPDATE `civicrm_state_province` SET `name`='DI Yogyakarta' WHERE `id` = 3085;
UPDATE `civicrm_state_province` SET `abbreviation`='KI' WHERE `id` = 3066;
-- CRM-15203 Handle MembershipPayment records while upgrade
INSERT INTO civicrm_membership_payment (contribution_id, membership_id) select cc.id, cm.id FROM civicrm_contribution cc LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id LEFT JOIN civicrm_membership cm ON cc.contribution_recur_id = cm.contribution_recur_id WHERE cc.contribution_recur_id IS NOT NULL AND cmp.id IS NULL AND cm.id IS NOT NULL;

View file

@ -0,0 +1 @@
{* file to handle db changes in 4.6.alpha2 during upgrade *}

View file

@ -0,0 +1,126 @@
{* CRM-16846 - This file may have been accidentally skipped and so is conditionally re-run during 4.6.6 upgrade *}
-- Use proper names for Slovenian municipalities
UPDATE `civicrm_state_province` SET `name` = (N'Ajdovščina') WHERE `id` = 4383;
UPDATE `civicrm_state_province` SET `name` = (N'Braslovče') WHERE `id` = 4392;
UPDATE `civicrm_state_province` SET `name` = (N'Brežice') WHERE `id` = 4395;
UPDATE `civicrm_state_province` SET `name` = (N'Črenšovci') WHERE `id` = 4402;
UPDATE `civicrm_state_province` SET `name` = (N'Črna na Koroškem') WHERE `id` = 4403;
UPDATE `civicrm_state_province` SET `name` = (N'Črnomelj') WHERE `id` = 4404;
UPDATE `civicrm_state_province` SET `name` = (N'Divača') WHERE `id` = 4406;
UPDATE `civicrm_state_province` SET `name` = (N'Domžale') WHERE `id` = 4414;
UPDATE `civicrm_state_province` SET `name` = (N'Gorišnica') WHERE `id` = 4419;
UPDATE `civicrm_state_province` SET `name` = (N'Hoče-Slivnica') WHERE `id` = 4426;
UPDATE `civicrm_state_province` SET `name` = (N'Hodoš') WHERE `id` = 4427;
UPDATE `civicrm_state_province` SET `name` = (N'Horjul') WHERE `id` = 4428;
UPDATE `civicrm_state_province` SET `name` = (N'Ilirska Bistrica') WHERE `id` = 4433;
UPDATE `civicrm_state_province` SET `name` = (N'Ivančna Gorica') WHERE `id` = 4434;
UPDATE `civicrm_state_province` SET `name` = (N'Juršinci') WHERE `id` = 4438;
UPDATE `civicrm_state_province` SET `name` = (N'Kidričevo') WHERE `id` = 4441;
UPDATE `civicrm_state_province` SET `name` = (N'Kočevje') WHERE `id` = 4444;
UPDATE `civicrm_state_province` SET `name` = (N'Križevci') WHERE `id` = 4452;
UPDATE `civicrm_state_province` SET `name` = (N'Krško') WHERE `id` = 4453;
UPDATE `civicrm_state_province` SET `name` = (N'Laško') WHERE `id` = 4456;
UPDATE `civicrm_state_province` SET `name` = (N'Loška dolina') WHERE `id` = 4464;
UPDATE `civicrm_state_province` SET `name` = (N'Loški Potok') WHERE `id` = 4465;
UPDATE `civicrm_state_province` SET `name` = (N'Luče') WHERE `id` = 4467;
UPDATE `civicrm_state_province` SET `name` = (N'Majšperk') WHERE `id` = 4469;
UPDATE `civicrm_state_province` SET `name` = (N'Mengeš') WHERE `id` = 4473;
UPDATE `civicrm_state_province` SET `name` = (N'Mežica') WHERE `id` = 4475;
UPDATE `civicrm_state_province` SET `name` = (N'Miklavž na Dravskem polju') WHERE `id` = 4476;
UPDATE `civicrm_state_province` SET `name` = (N'Mirna Peč') WHERE `id` = 4478;
UPDATE `civicrm_state_province` SET `name` = (N'Moravče') WHERE `id` = 4480;
UPDATE `civicrm_state_province` SET `name` = (N'Novo mesto') WHERE `id` = 4488;
UPDATE `civicrm_state_province` SET `name` = (N'Sveti Andraž v Slovenskih goricah') WHERE `id` = 4490;
UPDATE `civicrm_state_province` SET `name` = (N'Šalovci') WHERE `id` = 4492;
UPDATE `civicrm_state_province` SET `name` = (N'Šempeter-Vrtojba') WHERE `id` = 4493;
UPDATE `civicrm_state_province` SET `name` = (N'Šenčur') WHERE `id` = 4494;
UPDATE `civicrm_state_province` SET `name` = (N'Šentilj') WHERE `id` = 4495;
UPDATE `civicrm_state_province` SET `name` = (N'Šentjernej') WHERE `id` = 4496;
UPDATE `civicrm_state_province` SET `name` = (N'Šentjur') WHERE `id` = 4497;
UPDATE `civicrm_state_province` SET `name` = (N'Škocjan') WHERE `id` = 4498;
UPDATE `civicrm_state_province` SET `name` = (N'Škofja Loka') WHERE `id` = 4499;
UPDATE `civicrm_state_province` SET `name` = (N'Škofljica') WHERE `id` = 4500;
UPDATE `civicrm_state_province` SET `name` = (N'Šmarje pri Jelšah') WHERE `id` = 4501;
UPDATE `civicrm_state_province` SET `name` = (N'Šmartno ob Paki') WHERE `id` = 4502;
UPDATE `civicrm_state_province` SET `name` = (N'Šmartno pri Litiji') WHERE `id` = 4503;
UPDATE `civicrm_state_province` SET `name` = (N'Šoštanj') WHERE `id` = 4504;
UPDATE `civicrm_state_province` SET `name` = (N'Štore') WHERE `id` = 4505;
UPDATE `civicrm_state_province` SET `name` = (N'Tišina') WHERE `id` = 4507;
UPDATE `civicrm_state_province` SET `name` = (N'Trbovlje') WHERE `id` = 4509;
UPDATE `civicrm_state_province` SET `name` = (N'Tržič') WHERE `id` = 4512;
UPDATE `civicrm_state_province` SET `name` = (N'Turnišče') WHERE `id` = 4514;
UPDATE `civicrm_state_province` SET `name` = (N'Velike Lašče') WHERE `id` = 4517;
UPDATE `civicrm_state_province` SET `name` = (N'Veržej') WHERE `id` = 4518;
UPDATE `civicrm_state_province` SET `name` = (N'Zavrč') WHERE `id` = 4527;
UPDATE `civicrm_state_province` SET `name` = (N'Zreče') WHERE `id` = 4528;
UPDATE `civicrm_state_province` SET `name` = (N'Žalec') WHERE `id` = 4529;
UPDATE `civicrm_state_province` SET `name` = (N'Železniki') WHERE `id` = 4530;
UPDATE `civicrm_state_province` SET `name` = (N'Žetale') WHERE `id` = 4531;
UPDATE `civicrm_state_province` SET `name` = (N'Žiri') WHERE `id` = 4532;
UPDATE `civicrm_state_province` SET `name` = (N'Žirovnica') WHERE `id` = 4533;
UPDATE `civicrm_state_province` SET `name` = (N'Žužemberk') WHERE `id` = 4534;
-- Add missing Slovenian municipalities
INSERT INTO civicrm_state_province (country_id, abbreviation, name)
VALUES
(1193, "86", "Ankaran"),
(1193, "87", "Apače"),
(1193, "88", "Cirkulane"),
(1193, "89", "Gorje"),
(1193, "90", "Kostanjevica na Krki"),
(1193, "91", "Log-Dragomer"),
(1193, "92", "Makole"),
(1193, "93", "Mirna"),
(1193, "94", "Mokronog-Trebelno"),
(1193, "95", "Odranci"),
(1193, "96", "Oplotnica"),
(1193, "97", "Ormož"),
(1193, "98", "Osilnica"),
(1193, "99", "Pesnica"),
(1193, "100", "Piran"),
(1193, "101", "Pivka"),
(1193, "102", "Podčetrtek"),
(1193, "103", "Podlehnik"),
(1193, "104", "Podvelka"),
(1193, "105", "Poljčane"),
(1193, "106", "Polzela"),
(1193, "107", "Postojna"),
(1193, "108", "Prebold"),
(1193, "109", "Preddvor"),
(1193, "110", "Prevalje"),
(1193, "111", "Ptuj"),
(1193, "112", "Puconci"),
(1193, "113", "Rače-Fram"),
(1193, "114", "Radeče"),
(1193, "115", "Radenci"),
(1193, "139", "Radlje ob Dravi"),
(1193, "145", "Radovljica"),
(1193, "171", "Ravne na Koroškem"),
(1193, "172", "Razkrižje"),
(1193, "173", "Rečica ob Savinji"),
(1193, "174", "Renče-Vogrsko"),
(1193, "175", "Ribnica"),
(1193, "176", "Ribnica na Pohorju"),
(1193, "177", "Rogaška Slatina"),
(1193, "178", "Rogašovci"),
(1193, "179", "Rogatec"),
(1193, "180", "Ruše"),
(1193, "195", "Selnica ob Dravi"),
(1193, "196", "Semič"),
(1193, "197", "Šentrupert"),
(1193, "198", "Sevnica"),
(1193, "199", "Sežana"),
(1193, "200", "Slovenj Gradec"),
(1193, "201", "Slovenska Bistrica"),
(1193, "202", "Slovenske Konjice"),
(1193, "203", "Šmarješke Toplice"),
(1193, "204", "Sodražica"),
(1193, "205", "Solčava"),
(1193, "206", "Središče ob Dravi"),
(1193, "207", "Starše"),
(1193, "208", "Straža"),
(1193, "209", "Sveta Trojica v Slovenskih goricah"),
(1193, "210", "Sveti Jurij v Slovenskih goricah"),
(1193, "211", "Sveti Tomaž"),
(1193, "212", "Vodice");

Some files were not shown because too many files have changed in this diff Show more