Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: Drop a table using migration

I have a table that I created using the migrations, now I want to get rid of this table. I'm pretty sure I can just back out that migration, but I can't find the syntax to do that. I found this question from searching Rails DB Migration - How To Drop a Table?

but he basically says you can find what you need and provides a link. I read that link and I didn't see anything that says how to do it. I saw pieces of it, but I don't know how to put them together.

I see in the migration it has a self.down method, I really just need to know how to call that.

like image 298
Jhorra Avatar asked Aug 18 '11 01:08

Jhorra


2 Answers

Try to create an empty migration and use:

drop_table :table_name
like image 106
glarkou Avatar answered Sep 29 '22 15:09

glarkou


You can rollback the last migration with:

rake db:rollback

That will run the self.down method, which should be drop_table :table_name

like image 25
zetetic Avatar answered Sep 29 '22 16:09

zetetic