We have a MyISAM DB (don't ask me why we don't switch to InnoDB, it is not controlled by me).
Now I want DBIx::Class::Schema::Loader
to create relationships for *ID
columns adding s
to get table names. For example, Order.SeanceID
should relate table Order
with table Seances
.
Can DBIx::Class::Schema::Loader
be hacked to do this? Or is it better to write my own Loader?
Don't worry about "hacking" DBIx::Class::Schema::Loader to handle this. Just generate the classes and then add the relationships manually.
Every class that you generate with DBIx::Class::Schema::Loader will contain text at the bottom that looks like this:
# Created by DBIx::Class::Schema::Loader v0.07043 @ 2018-07-09 09:56:55
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6//4n3Crnz9U/q6GZ0Fwtg
# You can replace this text with custom code or comments, and it will be preserved on regeneration
As the last comment says, anything that you insert in the file beneath this text will be preserved if you regenerate the class. So you can safely add the relationship information to this section of the file manually and know that it will still be there the next time you regenerate the class.
Don't forget that you'll need to add both sides of the relationship - for example a has_many
relationship in a parent table and the reciprocal belongs_to
relationship in the associated child table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.