[Dbix-class] DBIx::Class::Schema::Loader limitations

Brandon Black blblack at gmail.com
Thu Jun 29 19:53:05 CEST 2006


On 6/29/06, Daniel McBrearty <danielmcbrearty at gmail.com> wrote:
> Or will Loader automatically
> detect and define realationships for us?

Yes, you just have to supply the optional parameter "relationships =>
1" (see perldoc DBIx::Class::Schema::Loader[::Base]), and it will load
up your relationships for you.

> Is this the point where we should start manually defining
> relationships and throw away Loader?

Especially if you're just now building your own database from scratch,
it really is best to build manual schemas and then deploy to your
rdbms via ->deploy, rather than the other way around (which is to
write SQL CREATE TABLE statements, deploy them manually, then use
Schema::Loader to create the schema).  The core arguments for the
former over the latter boil down to that DBIx::Class::Schema has more
metadata than your SQL DDL statements have, therefore it is the
preferred original source.

The big use-case for the Loader in the first place is primarily people
attaching to legacy databases over which they have little control or
design input.

An easy way to wean yourself is to use the new Schema::Loader feature
to dump the schema definition to a set of static class files, and then
take over manual maintenance from there (see the perldoc section on
"dump_to_dir" and "make_schema_at").  This functionality is a bit
clunky at the moment, but will eventually become a simple command in
the dbicadmin shell (or at least that's the plan).

Of course, you're free to keep using Loader all you want forever, its
just probably not the best practice. in most peoples' situations.

-- Brandon



More information about the Dbix-class mailing list