I added a table that I thought I was going to need, but now no longer plan on using it. How should I remove that table?
I've already run migrations, so the table is 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?
rails generate migration
has command-line options for generating migration code for creating tables, adding or changing columns, etc., it would be nice if it also had an option for dropping a table -- but it doesn't. Sure, writing theup
part is simple -- just calldrop_table
-- but thedown
part, generating the table again, might not always be so simple, especially if the schema of the table in question has been changed by migrations after its initial creation. Maybe someone should suggest to the developers of Rails that adding such an option would be a good idea. – Teemu Leistirake
migration-creation command, with the name of a table as a parameter, that would produce the neededup
anddown
functions. – Teemu Leisti