vnojhq
Last Updated: June 19, 2017
·
29
· lazybios
97eb92522d043b54ef01a9128b7176c0

drop table by migration

rails generate migration DropProductsTable

Good

class DropUsers < ActiveRecord::Migration
  def up
    drop_table :users
  end

  def down
    fail ActiveRecord::IrreversibleMigration
  end
end

Better (can reversible)

class DropUsers < ActiveRecord::Migration
  def change
    drop_table :users do |t|
      t.string :email, null: false
      t.timestamps null: false
    end
  end
end
Say Thanks
Respond