[Dbix-class] Howto convert from DB to Schema

Matt S Trout dbix-class at trout.me.uk
Tue Feb 7 15:46:43 CET 2006


On Mon, Feb 06, 2006 at 11:27:59AM -0500, James FitzGibbon wrote:
> I've read over DBIx::Class::Manual::SchemaIntro, but I'm still a bit
> confused as to how to move my DB-based set of classes over to Schema.
> 
> My current class hierarchy looks like this:
> 
> SPE::DA is-a DBIx::Class and loads the 'Core' and 'DB' components at compile
> time.  At runtime, it loads PK::Auto::Oracle or PK::Auto::Pg depending on
> the DBD in use.  This is shared among multiple projects.  From a discussion
> here about a month ago, it is important that the PK::Auto:: component be
> more to the left in the inheritance tree than Core and DB in order for
> ->insert to be overridden properly.
> 
> SPE::DA::DCH is for a specific project and is-a SPE::DA.  It has about 10
> subclasses (one for each table) in one file, statically defined.
> 
> Now, for me to convert to Schema, the docs seem to suggest that there is no
> longer a need for SPE::DA.  In the new world, SPE::DA::DCH is-a
> DBIx::Class::Schema and uses ->load_classes() to load all the statically
> defined subclasses, each of which is-a SPE::DA::DCH.

You don't want to make your table class isa your schema - the schema is
the thing that holds together ResultSource objects (usually one per table
class) and Storage, and is a separate thing. Doing everything by inheritance
is a Class::DBI-ism and the reason you can only have one connection per
class tree when using it.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list