本文介绍了更改列的 Rails 迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们有 script/generate migration add_fieldname_to_tablename fieldname:datatype 语法用于向模型添加新列.
We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model.
在同一行上,我们是否有用于更改列数据类型的脚本/生成?或者我应该将 SQL 直接写入到我的 vanilla 迁移中吗?
On the same line, do we have a script/generate for changing the datatype of a column? Or should I write SQL directly into my vanilla migration?
我想将一列从 datetime 更改为 date.
I want to change a column from datetime to date.
推荐答案我认为这应该可行.
change_column :table_name, :column_name, :date更多推荐
更改列的 Rails 迁移
发布评论