Is there any way to convert an already existing field (in production with a lot of content) from integer to decimal?
We need decimal support but there seems to be no way to change this once created.
It isn’t possible to change the field type once created. But what you could do is to add a new field for decimals and gradually migrate the content:
- In the Web App, create a new ‘Number’ > ‘Decimal’ field (same name of the existing field with appended ‘_decimal’)
- Use our Migration-CLI, and specifically
transformEntriesto copy the field contents to the new field:
- If you don’t want to delete the existing integer field right away, you could think of using a UI-extension to update the new decimal field whenever the integer field is modified:
- Once you are sure that the content is migrated, you should also remember to adapt your Frontend. Therefore you will need to disable the ‘integer’ field from the response in the Content-type editing
- After some time, if everything works correctly, you can then finally delete the ‘integer’ field from your Content-type