HI, guys,
How to remove a table with migration, i saw a drop down method in
migration created file , how can i use that ?
thank you.
HI, guys,
How to remove a table with migration, i saw a drop down method in
migration created file , how can i use that ?
thank you.
In rails 3.0.9:
bundle exec rake db:rollback
I just use the self.down method of origin migration that creates the
table to drop down the table
but the command ‘rake db:migrate’ not works.
2011/8/23, coolesting [email protected]:
you have to create a migration like this :
rails g migration deleteTableTableName
open the file generated and in the ‘up’ method you should enter this :
def up
drop_table :table_name
end
close the file en run
rake db:migrate
And that’s all
Good luck
Le 23 aot 2011 03:27, coolesting a crit :
On 23 August 2011 08:11, coolesting [email protected] wrote:
I just use the self.down method of origin migration that creates the
table to drop down the table
What do you mean by using the self.down method?
but the command ‘rake db:migrate’ not works.
Did you create a new migration with the drop table in as described by
Lionel or are you just trying to rollback the previous migration?
Colin
Can i rollback the specify table ?
for example, the ‘db/migrate’ directory have five migration files, i
want to rollback one of them,
if i use this command “rake db:migrate” that will rollback the lastly
table.
2011/8/23, Colin L. [email protected]:
bundle exec rake db:migrate:down VERSION=
On 23 August 2011 08:55, coolesting [email protected] wrote:
Can i rollback the specify table ?
for example, the ‘db/migrate’ directory have five migration files, i
want to rollback one of them,
It really is not a good idea to do that, better to make a new
migration. If you do rollback a migration that is not the last make
sure you then delete the migration or if you run them from the start
you will end up with the table back again. Also if any of the later
migrations reference that table you will be in trouble if you run the
migrations from scratch after deleting this one.
Colin
Good idea, if i need to rollback the migration that is not the lately
one, it must be confused to me or rails.
The good way is to create a new migration for rollbacking with the
related time.
2011/8/23, Colin L. [email protected]:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs