Details
-
Type: Task
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: None
-
Fix Version/s: Quest-CPS07
-
Component/s: None
-
Labels:None
Description
Summary
------------
Quest needs to retain Drupal user and CiviCRM core data for a subset of 2006 students and recommenders. However, they do NOT need to have the Quest component/schema data retained in this "Alumni" data set. This task is to write a command-line script (PHP or MySQL - whichever is easier) - which deletes Quest component table data for contacts which are being retained, and deletes ALL records for the other contacts.
Implementation
--------------------
Use this zipped dump of Quest 2006 data to develop/test the script:
http://svn.quest.civicrm.org/cividata/trunk/matchapp/civicrm_2006.sql.bz2
1. Delete all records for "students" who did not complete either the 2006 Preapp OR the 2006 College Match App. Logic for determining this is:
- if civicrm_contact.sub_type is 'Student' AND
- there are NO records in civicrm_task_status WHERE
responsible_entity_table = 'civicrm_contact' AND
responsible_entity_id = $contact_id AND
( (task_id = 2 AND status_id = 328) OR (task_id = 8 AND status_id = 328) )
For these contact records, delete the matching drupal user record (join on uf_match), the civicrm_contact and all associated civicrm core records (location, address, email, group_contact, relationship, task_status etc - probably by calling delete_contact function). AND the quest_student record and all associated quest component records (student_summary, person, transcript, test, counselor_evaluation etc.).
NOTE: I think there may be an existing delete_contact() which handles deleting the quest_* records (as otherwise we wouldn't be able to delete student contacts in the UI) - but pretty sure the Drupal user record deletion will need to be handled separately.
2. Delete all records for "recommenders" who didn't BEGIN a recommendation. Logic for determining this is:
- if civicrm_contact.sub_type is 'Recommender' AND
- there are NO records in civicrm_task_status WHERE
responsible_entity_table = 'civicrm_contact' AND
responsible_entity_id = $contact_id AND
task_id = 9
( We're not checking civicrm_task_status.status_id - as we're retaining anyone who even started a recommendation - even if it was cancelled or not completed. )
Delete scope is same as above - all related core civicrm records and all quest_* records.
3. Update the remaining contact records w/ contact_sub_type = 'Student', SET contact_sub_type = 'Alumni' . Leave contact_sub_type for Recommender contacts as-is.
3.1 Delete all records in civicrm_file and civicrm_entity_file. (We are doing this because Paras will be deleting the file-system files from last year for transcripts, tests etc and we don't want pointers to non-existent files in the DB.)
4. After running this script against the Quest 06 data, run the "cleaned" DB through the 1.5 -> 1.6 and then 1.6 to 1.7 DB upgrades. The resulting DB should run ok in the trunk environment (i.e. we should be able to view and edit core civicrm records). NOTE: If it's easier to do this in reverse order - that's fine (i.e. upgrade the core tables first from 1.5 to 1.7 and then clean out the unwanted records).