How to drop columns using Rails migration

前端 未结 20 787
执笔经年
执笔经年 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:27

    For removing column from table in just easy 3 steps as follows:

    1. write this command

    rails g migration remove_column_from_table_name

    after running this command in terminal one file created by this name and time stamp (remove_column from_table_name).

    Then go to this file.

    1. inside file you have to write

      remove_column :table_name, :column_name

    2. Finally go to the console and then do

      rake db:migrate

提交回复
热议问题