Skip to content

Instantly share code, notes, and snippets.

@geranyl
Created July 22, 2014 14:05
Show Gist options
  • Save geranyl/a1ba81a8337be9f48a6a to your computer and use it in GitHub Desktop.
Save geranyl/a1ba81a8337be9f48a6a to your computer and use it in GitHub Desktop.
Rails Tip on how to drop a table using migrations
rails generate migration DropSomeTable (where some is your table name)
It will generate a timestamped migration. They key is to place the drop table command in the up section
class DropSomeTable < ActiveRecord::Migration
def up
drop_table :some
end
def down
raise ActiveRecord::IrreversibleMigration <--optional
end
end
then run rake db:migrate VERSION=20140722133854, where the version is the timestamp on the file name. You should see it dropping the table and the schema.rb should change accordingly.
Note the file name will be 20140722133854_drop_some_table.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment