Posted on by

Understanding Possible Data Loss when Changing Field Form Element Type

When a field is defined in Participants Database, it creates a data column in the database table to store the information that field will collect. The way databases work, it’s more efficient to tell it what kind of data you intend to store. So, when a field’s form element is defined, the “datatype” in the database is changed to the best value for that kind of form element.

If you try to change the form element type for a field that has already got data in it, it’s possible to lose some or all of that data. The reason for that is that when the datatype in the database is changed, the type of data it can store is changed. If there is something incompatible in there, it is discarded. For instance, if you had text data stored in a field and you change the field to a numeric type, all that text data would be lost when the datatype changes because what was in there is now incompatible with the new type.

As long as there is no data stored in that field’s column in the database, there is no risk of data loss: there’s nothing to lose. It also won’t ever affect any other columns in the database when the configuration of a field is changed because they’re independent.

How to Avoid Data Loss

If you need to change the form element of a field that has stored data in it, it’s a good idea to have a backup of the database handy. Back up the database before you make any changes like that, and you’ll have a way to restore things if something happens. You can use a CSV export, or a database backup provided by a WordPress plugin. If you do need to use the backup, be sure to return the field to its original configuration before you try to restore the data.

After you change the form element type, check the data in your database. Chances are it will be OK.

In many cases, a good way to go is to just create a new field that has your new type and begin using that field instead. You can leave the old field in there if you want to keep that data. If you’re more adventurous and technically proficient, it is possible to try to get the old data into the new column. In many cases, this won’t work unless you fully understand what kind of data is stored in the new field and you know the old data is compatible or you can convert it to a compatible format. In that case, you can alter a CSV file to import the data from the old field into the new one.

If you have any specific questions about changing the field’s form element and it’s possible effect on the stored data, ask in the support forum.

 

Leave a Reply
You have to agree to the comment policy.

Leave a Reply
You have to agree to the comment policy.