gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:39:44 25 4
gpt4 key购买 nike

我有一个架构:

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

关于elixir - 如何更改 Ecto 中的字段类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32583625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com