Hi all,
I have a country_code
column in one of my tables of a phoenix API app and I’m currently considering on whether I should have it as an enum
or a string
that I could validate against for a wrongly specified country that would be saved in the DB via an API call to the app.
I basically want to prevent a wrong country name from being stored and I can validate this against a country_code enum type or basically make use of a country_code string to save the country type and validate that against a constant that has a list of allowed country names.
My question is as we update the enum type to add more ‘allowed’ countries, how does this potentially affect a live app in terms of updating the existing DB to introduce the new enum type? Let’s assume this DB already has millions of records. If it can get very challenging and result in potential downtime when we have to do this, would it be a better option to have the country_code as type string ? Does Erlang/Elixir/Phoenix/Ecto has a better way to handle such things which can allow me to easily use the enum type
without any necessary downtime? If so, I’d prefer to go with the enum type as the validations are given out of the box.
Would be great to hear your thoughts on this if there is something to help me with updating an enum type in seamless way.
Thank you.