[Dbix-class] Question about dynamic class generation
(DBIx::Class::Schema::Loader)
Brandon Black
blblack at gmail.com
Tue Feb 14 14:27:03 CET 2006
On 2/14/06, castaway at desert-island.demon.co.uk
<castaway at desert-island.demon.co.uk> wrote:
>
> On Tue, 7 Feb 2006, Brandon Black wrote:
>
> > 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.
>
> I just went "huh?" here.. What is different about a DB that's been
> designed with DBIx::Class in mind? Or did you just mean "properly
> normalised" ?
>
I think I just meant that you already have database code running
before you ever heard of DBIx::Class. If you started out with
DBIx::Class in mind, you might have built the database a Schema
definition + SQLT instead, which would obviate Loader.
> > 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?]
>
> Great idea! ;)
>
> > 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.
>
> IMO (and I may be off base), it should be possible to use Loader, which
> will have a standard set of predictable results (which should be detailed
> in the docs), and then only write your own classes for the parts you need
> to change / expand. Some flag should possibly set whether the user-created
> classes replace or extend the Loader ones .. ?
>
Probably should be such a flag. But it's also pretty easy when you
get to that point (or should be) to just dump out your whole Loader'd
Schema via SQLT and just drop Loader at that point and start working
manually.
-- Brandon
More information about the Dbix-class
mailing list