Brian
Brian

Reputation: 6071

Ruby on Rails rake db:drop

Is there a command to drop a specific table in the database and not all of them?

Or a way to update a database table

Thank you.

Upvotes: 0

Views: 7449

Answers (2)

Anubhaw
Anubhaw

Reputation: 6068

This can be achieved using migration with following command:-

def self.up    
  drop_table :table_name   
end

Upvotes: 1

Pär Wieslander
Pär Wieslander

Reputation: 28934

Check out the Ruby on Rails Migration Guide. For example, to drop a table in a migration:

class DropProducts < ActiveRecord::Migration
  def self.up
    drop_table :products
  end

  def self.down
    raise ActiveRecord::IrreversibleMigration
  end
end

Upvotes: 6

Related Questions