Changing a field's data type

Changing a field's datatype requires a few steps. Select the field that you need to edit in the Admin interface and change the "Data Type" to the new type. For instance, you may be changes a Yes/No to a dropdown; therefore, select "Enum," which is the ZEPRS data type for dropdowns. Next change the "Widget" - in the case, it will be a "Dropdown." Go to the SQ: concole form, select "SQL Type" to batch and enter the SQL statement(s) to change the datatype in mysql. In this instance, it would be:

alter table zeprs.arvregimen CHANGE receivedRegimen receivedRegimen int(11);

alter table zeprs.deliverysum CHANGE mother_received_arv mother_received_arv int(11);

If the sql was executed successfully, the system will display "Query successful: 2 SQL statements" to the right ofthe SQL data entry box.

Make sure that the "Log" checkbox is checked - this will make this schema change execute on the master server or any other instances of the database.

You'll also need to convert current values to the new enumeration id's:

 

update zeprs.arvregimen set receivedRegimen = 3197 where receivedRegimen = 1;
update zeprs.arvregimen set receivedRegimen = 3198 where receivedRegimen = 0;

Restart the application in order to generate the updated XML for the form.