How to drop columns using Rails migration

前端 未结 20 762
执笔经年
执笔经年 2020-12-12 08:50

What\'s the syntax for dropping a database table column through a Rails migration?

20条回答
  •  萌比男神i
    2020-12-12 09:29

    Through
    remove_column :table_name, :column_name
    in a migration file

    You can remove a column directly in a rails console by typing:
    ActiveRecord::Base.remove_column :table_name, :column_name

提交回复
热议问题