Search code examples
ruby-on-railssql-drop

How to create a migration deleting a table in ruby on rails


I want to delete a table in my rails app but i cannot use rollback, because i created this table a long time ago, and i have a LOT of other tables created since that one.

How is supposed to be named a drop table migration file and is there a way to genrate it with rails generate?


Solution

  • Create one more migration to drop the table. The class should have the method

    def self.up
      drop_table :table_name
    end
    

    Be careful as you will not be able to rollback to get all the data you will lose while dropping the table.