How to drop columns using Rails migration

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

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

20条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 09:46

    remove_column in change method will help you to delete the column from the table.

    class RemoveColumn < ActiveRecord::Migration
      def change
        remove_column :table_name, :column_name, :data_type
      end
    end
    

    Go on this link for complete reference : http://guides.rubyonrails.org/active_record_migrations.html

提交回复
热议问题