How to rename a column and change its type by migration same time

后端 未结 4 1443
迷失自我
迷失自我 2021-02-06 23:43

In my general_exams table, I have a column named semester, type is string. Now I want to change its name to semester_id, type

4条回答
  •  情歌与酒
    2021-02-07 00:20

    This works as of Rails 4

    def change
      rename_column :general_exams, :semester, :semester_id
      change_column :general_exams, :semester_id, :integer
    end
    

提交回复
热议问题