[Dbix-class] copy between databases, suggestions needed
Matt S Trout
dbix-class at trout.me.uk
Wed Jan 11 01:50:17 CET 2006
On Tue, Jan 10, 2006 at 03:28:48PM -0800, Alan Humphrey wrote:
> I'm using the Schema feature to access two databases. My application has a
> staging database and a production database. Users will enter/edit data in
> the staging database and when it's ready for public consumption it is
> promoted to the production database.
Currently,
my $cls = 'Foo';
my $obj = My::DB1->class($cls)->find($val);
($obj is a My::DB1::Foo object)
bless($obj, My::DB2->class($cls));
$obj->in_storage(0); $obj->insert;
> My question is this: what is the best way to do the promotion? The copy
> method seems geared to making a variant of an existing record in the same
> table/database.
Right. Very few people are actually using multiple copies of the same Schema
at once, so there's not an amazing amount of helper code yet :)
> I think I'll have to create my own "promote" method. The field copy would
> be straightforward, but what's the best way to handle the relationships?
using SchemaClass->class($cls) to resolve the class names to move to, I'd
suspect. You may also want to have a look at the way the branch is structured;
things like schema, storage etc. can just be objects to a large extent (and
all classdata can be overriden on a per-object basis) which may make your life
substantially simpler :)
--
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