更改列的 Rails 遷移 - Rails migration for change column

問題:

We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model.我們有script/generate migration add_fieldname_to_tablename fieldname:datatype語法用於向模型添加新列。

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?或者我應該將 SQL 直接寫入我的 vanilla 遷移中嗎?

I want to change a column from datetime to date .我想將一列從datetime更改爲date


解決方案:

參考一: https://stackoom.com/question/BkLe
參考二: Rails migration for change column
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章