I created a table that i thought i would need but now i don't plan to use it Tell me the easiest way to remove the table?

I've already run migrations to the table in my database I figure rails generate migration should be able to handle this, but I haven't figured out how yet.

I've tried:

rails generate migration drop_tablename

but that just generated an empty migration.

What is the "official" way to drop a table in rails?

Best Answer


You won't always be able to simply generate migration to already have the code you want You can create an empty migration and then populate it with the code you need

You can find information about how to do different tasks in a migration here

http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

You can specifically see how to drop a table using the following approach

drop_table :table_name