Rails migration for change column

后端 未结 9 1060
一个人的身影
一个人的身影 2020-11-28 17:24

We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model.

On the same line, do we have a

9条回答
  •  遥遥无期
    2020-11-28 18:15

    You can also use a block if you have multiple columns to change within a table.

    Example:

    change_table :table_name do |t|
      t.change :column_name, :column_type, {options}
    end
    

    See the API documentation on the Table class for more details.

提交回复
热议问题