大家好,我正在寻找方法来更改字段类型并在此期间转换其值。
我的意思是类似的东西:如何通过算法修改ecto中的字段
def up do
alter table(:users) do
modify :role, :integer, default: fragment("convertion_function")
end
end
我知道Ecto.Migration#modify/3
功能得到&fragment/1
说法。但它只有一个参数。
有谁知道是否可以通过当前值&fragment/1
函数?
或者,也许有人知道更好的方式来做到这一点?
谢谢你,Dogbert。有用! – CarefreeSlacker