Created
July 22, 2014 14:05
-
-
Save geranyl/a1ba81a8337be9f48a6a to your computer and use it in GitHub Desktop.
Rails Tip on how to drop a table using migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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