How to Drop table in rails

 

  Step 01 :::  Run the below command  :: This will create new migration file 

rails generate migration drop_tablename

  Step 02 :::  Add these below two methods in that migration

  def up
    drop_table :products
  end

  def down
    raise ActiveRecord::IrreversibleMigration
  end

Step 03 ::: rake db:migrate 


This will drop the Table.


Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5