in Programming, Uncategorized

Rails: Remove a table

I created a table that I did not need. I needed to remove the table. The actual terminology is to Drop a table. The way you do this is to create a new migration.

rails g migration DropProducts

In my case, I created a products table when I didn’t needed it. Inside the migration, I do the following.

class DropProducts < ActiveRecord::Migration
  def change
    drop_table :products


Write a Comment


    • Depends on when you’ve made the migration. If this is production code, then I wouldn’t delete it. But if it is just development, then you could delete the previous migration and run your migrations again.