如何更改 Ecto 中的字段类型?

How to change field type in Ecto?

我有一个模式:

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

    timestamps
  end

现在我想将一个字段表单的类型 :integer 更改为 :binary。 编写迁移的正确方法是什么,因为使用 add 不起作用...?

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

      timestamps
    end
  end

您必须使用 modify/3 来更改类型。 add/3 仅用于添加新列。

alter table(:editables) do
  modify :content, :binary
end