How to drop a table in Rails 5

To drop a table in Rails 5, run the following migration. Change Posts to the name of your table, and make sure it’s plural.

rails g migration DropPosts

Open up the migration you’ve just generated inside db/migrate, and change it to the following:

class DropPosts < ActiveRecord::Migration[5.2] # change `Posts`
def change
drop_table :posts # change `posts`
end
end

Then run rails db:migrate. Your table should now be dropped.

I'm Mark Thomas Miller, an engineer, designer, and maker of things.