Rails 5: How to remove a column from a database?

To remove a column with migration:

rails g migration Remove..From.. col1:type col2:type col3:type

In your case:

rails g migration RemoveCountryFromSampleApps country:string

This will generate the following migration in Rails 5.0:

class RemoveCountryFromSampleApps < ActiveRecord::Migration[5.0]
  def change
    remove_column :sample_apps, :country, :string
  end
end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)