
Automigration of HABTM
Reported by Josh H | November 13th, 2007 @ 03:58 PM
auto_migrate!
should generate a mapping table for has_and_belongs_to
associations. Problem: Both models in habtm relation will try creating table. Solution: Either this is not a problem (we just catch the exception), or we check to see if the table exists first.
Comments and changes to this ticket
-
Sam Smoot November 17th, 2007 @ 04:48 AM
- State changed from new to resolved
This is done in r509.
I just auto-migrate an HABTM association join table whenever you auto-migrate the class it's declared on. If you declare the association on both sides, and auto-migrate both classes, this means the join-table will be created twice. Which isn't a technical problem. It's not the most efficient way to handle it perhaps, but eh, it's not like you need to squeeze absolute performance out of migrations, so who cares. :-)
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »