Elixir Ecto, failed change type to jsonb

ecto
phoenix

#1

I have an error while modifying column type to jsonb or map. Here is my migration file:

def change do
    alter table(:disbursements) do
      modify :reason, :map
    end
  end

and I receive error like below:

** (Postgrex.Error) ERROR 42804 (datatype_mismatch) column "reason" cannot be cast automatically to type jsonb

hint: You might need to specify "USING reason::jsonb".
(ecto_sql) lib/ecto/adapters/sql.ex:624: Ecto.Adapters.SQL.raise_sql_call_error/1

My question is how can I add extra command USING reason::jsonb to my migration file ?


#2
  def change do
    alter table(:disbursements) do
      modify :reason, :jsonb
    end
  end