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

后端 未结 4 1441
迷失自我
迷失自我 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:16

    I hope this help

    class ModifyColumnTables 
      def change
        remove_column :posts, :old_column
        add_column :posts, :new_column, :type_of_column
      end
    end
    

提交回复
热议问题