Dashboard > CiviCRM Documentation > ... > Upgrade Drupal Sites to 2.0 > Migrate 3rd Party Activity History Records to 2.0
Migrate 3rd Party Activity History Records to 2.0 Log In | Sign Up   View a printable version of the current page.

 Contents
  Documentation Home
This document provides steps needed to ensure that Activity History records from 3rd party modules are migrated to the 2.0.x data structure when a 1.9 site is upgraded. You should review these steps if your CiviCRM installation includes integration with another module or custom code which has generated Activity History records displayed under Contacts' Activity tab.

Enter Additional Activity Types BEFORE Running the 2.0 Database Upgrade Script

Starting with version 2.0, all "transactions" are stored as Activities (the separate Activity History table has been eliminated). The 2.0 upgrade script will automatically move existing Activity History records into the Activity table structure for all recognized activity types. In order to make sure your 3rd party Activity History records are migrated - you'll need to input activity types for each instance as follows. Note that the callback column no longer exists. This means that the "view" link on your custom activity records no longer points to the original source.

  • Using phpMyAdmin for MySQL from the command line, run the following query to identify unique activity types used in your site:
    SELECT DISTINCT(activity_type) FROM civicrm_activity_history;
  • Login to your CiviCRM site with administrator-level permissions.
  • Navigate to Administer CiviCRM » Activity Types
  • Add Activity Types for each 3rd party type. You do NOT need to add activity types for actions which are related to CiviContribute, CiviEvent, CiviMember, CiviMail and Send Email functions.
  • You can now proceed with the 2.0 upgrade instructions.

If there are Activity History records which do NOT have a matching activity type - the upgrade will give you a warning message when it completes. These records will be retained in the civicrm_activity_history table. You can refer to the comments attached to this issue for information about manually migrating these "post-upgrade". OR, assuming you still have your 1.9 database - you can start over - adding the remaining activity types before running the upgrade.

Code contributions from Dave Hansen-Lange

Here is how Dave Hansen-Lange addressed the issue for a Advomatic client

If you want your activity history records to be moved to the new activity table, run the following code before you run the upgrade wizard step 4.

function create_custom_activity_types($domain_id = 1) {

  db_set_active('civicrm');

  $activity_type_group_id = db_result(db_query("SELECT id FROM civicrm_option_group WHERE domain_id = %d AND name = 'activity_type'", $domain_id));

  $activity_type_value = db_result(db_query('SELECT MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = %d', $activity_type_group_id));
  $activity_type_value ++;

  $activity_type_weight = db_result(db_query('SELECT MAX(weight) FROM civicrm_option_value WHERE option_group_id = %d', $activity_type_group_id));
  $activity_type_weight ++;

  $result = db_query('SELECT DISTINCT activity_type FROM civicrm_activity_history WHERE activity_type IS NOT NULL');
  while ($activity = db_fetch_object($result)) {
    db_query("INSERT INTO civicrm_option_value (option_group_id, label, value, name, grouping, filter, is_default, weight, description, is_optgroup, is_reserved, is_active) 
      VALUES ($activity_type_group_id, '$activity->activity_type', '$activity_type_value', '$activity->activity_type', NULL, 1, NULL, $activity_type_weight, '$activity->activity_type', 0, 1, 1);");
    $activity_type_value ++;
    $activity_type_weight ++;
  }

  db_set_active();
  
}

Added by David Greenberg , last edited by dave hansen-lange on Apr 03, 2008  (view change)
Labels: 
(None)

Recently Updated  |  Documentation Credits

Earlier versions used the label "Email Sent" in this table. The upgrade script expects this to be "Email" and reports this to be 3rd party data. The following mysql statement prepared those records for input without an error message:

UPDATE civicrm_activity_history SET activity_type = "Email" WHERE activity_type = "Email Sent"
Powered by a free Atlassian Confluence Open Source Project License granted to CiviCRM . Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators