[Dbix-class] Question about dynamic class generation (DBIx::Class::Schema::Loader)

Brandon Black blblack at gmail.com
Tue Feb 7 16:48:01 CET 2006


On 2/7/06, Leandro Hermida <leandro.hermida at unibas.ch> wrote:
>
> Hello,
>
> I read in the digest that doing dynamic schema class generation via
> DBIx::Class::Schema::Loader should not be used in production environments.
> Is this true only because it is so new?  Or that it won't be recommended in
> general for the life of the module? (due to the way it works or something)
>

Well, Schema::Loader is very new, I wouldn't really trust it until at
least 0.02.  At the same time, much of the code is either directly
from or mechanically translated from DBIx::Class::Loader.  But all of
that aside, Schema::Loader is probably not want you want in the long
run in a big app with a big/complex database schema (in development or
production - just in general).  It's purpose is to get people up and
running quickly against an existing database that wasn't built with
DBIx::Class in mind, or is created/managed by other tools at the time.

It tries to divine the ideal DBIx::Class::Schema setup based on what
it can see on your live running database server, but it cannot
possibly get it all correct - it will always be just a good
approximation of what you might have done if you defined the Schema
manually when it comes to relationships and such.

[I think I've written the above in some form like 4 times now to
various people, perhaps I should patch that into the Schema::Loader
documentation?]

Unless your app/db is fairly simplistic, you will probably want to
migrate off of Schema::Loader after a while, and you'd do that by
using the DBIx::Class SQLT support to dump the
Schema::Loader-generated Schema out to a manual definition that you
can edit and refine from there.

The SQLT support that Matt mentioned (generating CREATE TABLE stuff
from a DBIx::Class::Schema) goes in the opposite direction of
Schema::Loader, and should be the more robust and preferred solution
that matches up more with the others you mentioned.

-- Brandon



More information about the Dbix-class mailing list