The following query moves ah membership records to the activity table:
SELECT @ov_id_membership := value FROM civicrm_option_value WHERE option_group_id = @og_id_at AND label='Membership Signup';
INSERT INTO civicrm_activity (`source_contact_id`, `source_record_id`, `activity_type_id`, `subject`, `activity_date_time`, `due_date_time`, `duration`, `location`, `phone_id`, `phone_number`, `details`, `status_id`, `priority_id`, `parent_id`, `is_test`)
SELECT ah.entity_id, ah.activity_id, @ov_id_membership, ah.activity_summary,
ah.activity_date, NULL, NULL, NULL, NULL, NULL,
ah.activity_summary, @ov_id_completed, NULL, NULL, ah.is_test
FROM civicrm_activity_history ah
WHERE ah.module IN ('CiviMember') AND ah.activity_type='Membership - New'
GROUP BY ah.module, ah.entity_id;
But what about all the records where activity_type != 'Membership - New'? See
CRM-2914 for a list of such ah records.
I caught this while working on another bug. But I won't have opportunity to work on it during this project since my current project has no membership data.