Question

I am currently using the DBIC Schema Loader function make_schema_at to dump my existing database into its schema. Once the schema is dumped I generally like to go in and clean up the accessor names in the relationships to read better.

However from time to time I need to update my schema again, for example adding in a new table and relationship which means calling make_schema_at again and then renaming all of my accessors which is very time consuming.

Is there a better approach to this that anyone can recommend?

thank you.

Was it helpful?

Solution

Yes, there are multiple solutions for this.

Either use the configuration options of Schema::Loader to specify subs for name generation and/or make your DBIC schema the master.

In this case you write a new result class instead of creating the table in your database and use DBIC's feature to generate the DDL queries.

You can even use DBIx::Class::Migration to automate the DDL changes to your databases.

OTHER TIPS

Never edit the code above the MD5 hash in a generated DBIC schema file. you'er just making trouble for yourself.

It's well worth taking the time to read the documentation for DBIx::Class::Schema::Loader::Base. In particular, take a close look at the "moniker_map", "col_accessor_map" and "rel_name_map" attributes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top