[Rails] Re: Proper way to back out a bad migration?

2010-12-07 Thread pepe
> Typically I do rake db:migrate VERSION=0
> But that  also gave me the same error about "Primary key is not allowed in a
> has_and_belongs_to_many join table"
>
> So I then fired up dbconsole and manually dropped the table.
>
> But now I even if I run rake db:migrate the join table isn't created -
> probably because it 'think' it had run it previously.

I believe the problem you've been running into is that your schema
migrations table still has the number of the migration(s) you removed
manually. When the rake task runs it sees the numbers there and says
"OK, that one is done" so it skips the migration. I think the best
thing to do in that case is to manually delete the record(s) in the
schema migrations table in order to be able to rerun them.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Proper way to back out a bad migration?

2010-12-06 Thread Marnen Laibow-Koser
Rick R wrote in post #966751:
> I'm curious on the best practice to remedy this situation...
>
> I created a habtm migration but forgot the :id => false
>
> I ran the migration (rake db:migrate)
>
> I tried to run my tests and then go the error that made me realize I
> forgot
> the :id => false.
>
> The question is how do I back out my changes?

rake db:rollback (assuming you wrote your down method correctly in the 
migration!).
>

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.