Deleting Records

From IHRIS Wiki

The functionality to delete records is available in the 4.0.11 codebase.

A record, is just one instance of a form, for example a specific person form, person|1234.

Enabling the Delete Record Module

In order to delete records, you will need to enable the deleteRecords module. To do so go to:

  • Configure System
  • Configure Modules
  • Click the "Sub-Modules" link to the right of the "Pages" module
  • Click the "Sub-Modules" link to the right of the "Admin" module
  • Select the "Delete

Deleting Records

Before you begin, Back up your database!! As this feature has not been extensively tested and there are no "safe guards" you will want to back up the database so you can recover from any mistakes.

The delete records is only a "command line" only feature. It is not available to the web-interface. To use it, you should open up a terminal to get to the command line. Now change to the directory of your site that contains the index.php file. For example: <source lang='bash'> cd /var/www/iHRIS/manage </source> or <source lang='bash'> cd /var/lib/iHRIS/sites/4.0/manage/pages </source>

The deleteRecord has been registered as a sub-page of the admin module. So, once you are in the same directory as index.php, you can use the delete record feature by: <source lang='bash'> php index.php --page=/admin/deleteRecord </source>

Rules for Operation

  • Whenever deleting a form instance (or record) you are forced to also delete any child forms of that record
    • For example, when deleting a person form, there may be one or more child forms person_position that will be need to be deleted.
  • Whenever deleting a record, it will show you and all the forms that the form link to
    • For example a person_position form links to a position form. If that position form was created just for that person, you may want to delete that position
  • Whenever deleting a record, it will show you all the forms that link to that form
    • For example, if you are deleting a position form, there may be one or more person_position forms that link to that position. Once you have deleted a position, than you 'must delete these person_position forms.

Clearing Out Cached Data

Once we have deleted a record, we need to clear out any cached data referring to that record. The simplest way is to restart apache and memcached: <source lang='bash'>

sudo /etc/init.d/apache2 restart
sudo /etc/init.d/memcached restart

</source>

Example Output

Here is an example of deleting a person from the iHRIS Manage Demonstration site. <source lang='bash'> litlfred@cumin:/var/www/iHRIS/4.0-dev/manage$ php index.php --page=/admin/deleteRecord </source> We have run the command, the first thing it asks us is which record we want to delete. We tell it person|8549 and Show the details of that person to ensure we have the correct one <source lang='bash'> Please enter the form and ID of the record you wish to delete. For example person|1000.: person|8549 Array (

   [0] => person|8549

) Would you like to delete records related to person|8549? (Yes/No/Show): s firstname => Baicr nationality => country|TAI othername => residence => district|24 surname => Thaiwi surname_ignore => 0 password =>

</source> We now verify that we have the correct person so we continue with the deletion process <source lang='bash'> Would you like to delete records related to person|8549? (Yes/No/Show): y Please select child forms related to person|8549 to delete [X] 0) person|8549 Links By nationality To country|TAI Links By residence To district|9 Child Forms: [X] 1) person_position|8551 Links By position To position|8548 Parent Form person|8549 Child Forms: [X] 2) salary|8552 Links By salary To currency|1 Parent Form person_position|8551 [X] 3) demographic|8550 Links By gender To gender|F Links By marital_status To marital_status|1 Parent Form person|8549 Please select an option or enter q to quit selection process: q Would you like to delete all the selected forms linked person|8549 as children/grand-children? (Yes/No): y I2CE: I2CE->raiseError (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:180) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:132) I2CE_Page_DeleteRecord->actionCommandLine (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Page.php:492) I2CE_Page->display (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Wrangler.php:89) I2CE_Wrangler->wrangle (/home/litlfred/rocket_cats/dev/ihris-manage/sites/Demo/pages/index.php:60): Deleting person|8549 I2CE: I2CE->raiseError (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:180) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:194) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:132) I2CE_Page_DeleteRecord->actionCommandLine (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Page.php:492) I2CE_Page->display (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Wrangler.php:89) I2CE_Wrangler->wrangle (/home/litlfred/rocket_cats/dev/ihris-manage/sites/Demo/pages/index.php:60): Deleting person_position|8551 I2CE: I2CE->raiseError (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:180) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:194) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:194) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:132) I2CE_Page_DeleteRecord->actionCommandLine (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Page.php:492) I2CE_Page->display (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Wrangler.php:89) I2CE_Wrangler->wrangle (/home/litlfred/rocket_cats/dev/ihris-manage/sites/Demo/pages/index.php:60): Deleting salary|8552 I2CE: I2CE->raiseError (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:180) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:194) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:132) I2CE_Page_DeleteRecord->actionCommandLine (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Page.php:492) I2CE_Page->display (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Wrangler.php:89) I2CE_Wrangler->wrangle (/home/litlfred/rocket_cats/dev/ihris-manage/sites/Demo/pages/index.php:60): Deleting demographic|8550 Would you like to delete records related to country|TAI: Taifafeki? (Yes/No/Show): n Would you like to delete records related to district|9: Gatarama, East, Taifafeki? (Yes/No/Show): n Would you like to delete records related to gender|F: Female? (Yes/No/Show): n Would you like to delete records related to marital_status|1: Single? (Yes/No/Show): n Would you like to delete records related to position|8548: CHO101: Nurse (Gisamba Hospital, Emergency Service)? (Yes/No/Show): s i2ce_hidden => 0 code => CHO101 comments => department => department|10 description => facility => facility|4 interview_comments => job => job|2230-1B posted_date => 1990-10-13 pos_type => | proposed_end_date => 0000-00-00 00:00:00 proposed_hiring_date => 1990-10-13 proposed_salary => = source => status => position_status|closed supervisor => position|8528 title => Nurse

Would you like to delete records related to position|8548: CHO101: Nurse (Gisamba Hospital, Emergency Service)? (Yes/No/Show): y Please select child forms related to position|8548 to delete [X] 0) position|8548 Links By department To department|10 Links By facility To facility|4 Links By job To job|2230-1B Links By status To position_status|closed Links By supervisor To position|8528 Please select an option or enter q to quit selection process: q Would you like to delete all the selected forms linked position|8548 as children/grand-children? (Yes/No): y I2CE: I2CE->raiseError (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:180) I2CE_Page_DeleteRecord->deleteForms (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/modules/Admin/modules/DeleteRecord/lib/I2CE_Page_DeleteRecord.php:132) I2CE_Page_DeleteRecord->actionCommandLine (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Page.php:492) I2CE_Page->display (/home/litlfred/rocket_cats/dev/I2CE/modules/Pages/lib/I2CE_Wrangler.php:89) I2CE_Wrangler->wrangle (/home/litlfred/rocket_cats/dev/ihris-manage/sites/Demo/pages/index.php:60): Deleting position|8548 Would you like to delete records related to person_position|8551? (Yes/No/Show): n Would you like to delete records related to currency|1: TF ¤? (Yes/No/Show): n Would you like to delete records related to department|10: Emergency Service? (Yes/No/Show): n Would you like to delete records related to facility|4: Gisamba Hospital? (Yes/No/Show): n Would you like to delete records related to job|2230-1B: Nurse? (Yes/No/Show): n Would you like to delete records related to position_status|closed: Closed? (Yes/No/Show): n Would you like to delete records related to position|8528: CHO97: Nurse (Gisamba Hospital, Emergency Service)? (Yes/No/Show): n litlfred@cumin:/var/www/iHRIS/4.0-dev/manage$ sudo /etc/init.d/apache2 restart

  • Restarting web server apache2
 ... waiting     

litlfred@cumin:/var/www/iHRIS/4.0-dev/manage$ sudo /etc/init.d/memcached restart Restarting memcached: memcached. </source>

Preserving Deletions

All records that are deleted are automatically stored in the database in the form_history table with the deletion time and all the data stored as a json encoded string.