To remove a column from a table in Rails 5, run the following migration:
rails g migration RemoveFieldNameFromTableName field_name:datatype
Make sure to change the migration to use your column and table name. For instance,
rails g migration RemoveTitleFromPosts title:string
This will generate the following migration:
class RemoveTitleFromPosts < ActiveRecord::Migration[5.2]
def change
remove_column :posts, :title, :string
end
end
Then run rails db:migrate
.