Subject: | preserve names of existing relationships if the relationship info matches |
Date: | Sun, 24 Oct 2010 23:03:04 +0000 |
To: | bug-dbix-class-schema-loader [...] rt.cpan.org |
From: | Stephen Bennett <stephen [...] freenode.net> |
23:52:05 <@ribasushi> hobbs: it needs to simply interrogate the old class before it overwrites it
23:52:11 <@ribasushi> hobbs: collect a list of relinfos
23:52:22 <@ribasushi> hobbs: compare them against what we infer from the db
23:52:25 <@ribasushi> if found - keep the name
23:52:44 <@ribasushi> it's easy, just tedious
23:53:45 <@ribasushi> hashing a dump of the relinfo ought to do it
I had two tables, contacts and group_contacts. group_contacts contains a
column contact_id, referencing contacts.id. S::L creates a has_many
'group_contacts' in Contact.pm.
I now add a second column to group_contacts, also referencing
contacts.id, and re-run S::L. It now generates two different has_many
relations, referring to the two columns that reference contacts.id,
but crucially the original group_contacts relation is now called
group_contacts_contacts. All code using the schema is now broken. The
above IRC log snippet suggests a fix.