How to change field type in Ecto?

2019-02-02 23:32发布

I have a schema:

schema "editables" do
    field :title, :string
    field :content, :string

    timestamps
  end

Now I want to change the type of one field form :integer to :binary. What's the correct way of writing the migration because using add is not working...?

def change do
    alter table(:editables) do
      add :title, :binary
      add :content, :binary

      timestamps
    end
  end

1条回答
The star\"
2楼-- · 2019-02-03 00:18

You have to use modify/3 to change the type. add/3 is only for adding new columns.

alter table(:editables) do
  modify :content, :binary
end
查看更多
登录 后发表回答