Convert string column to integer in DB

So what is the point in converting it into an integer then? OH! You’re trying to use ecto_enum library. Just use the built in Ecto.Enum — Ecto v3.14.0 type. It works fine with strings.

EDIT: If you’re trying to get the sortability property, I would seriously just consider using a proper database enum type and not trying to convert into integers.

IF however you really want to do this, here is how:

  1. Make a new column of type integer called new_column_name.
  2. Run a series of updates:
update table_name set new_column_name = 0 where column_name = "verifiy"
update table_name set new_column_name = 1 where column_name = "invite"
... etc
  1. Drop the old column and rename the new column to column.