I have a model with a column of type integer which I want to convert to type string. Now I’m looking for the best way to change the column type without losing the data. Is there a painless way to accomplish this?
I have a model with a column of type integer which I want to
Share
A standard migration using the change_column method will convert integers to strings without any data loss. rake db:rollback will also do the reverse migration without error if required.
Here is the test migration I used to confirm this behaviour: