[Dbix-class] Adding relationships to an already-constructed schema

Toby Corkindale toby.corkindale at strategicdata.com.au
Thu Apr 2 04:05:04 BST 2009


Toby Corkindale wrote:
> Hi,
> Start by assuming I'm smoking crack and do actually want to do this.. :)
> 
> If I have a $schema that is already initialised, and I decide I want to 
> add a new relationship to one of my tables, what is the proper way to do 
>  so?
> 
> Is it this?
> my $schema = ExampleApp->connect(..);
> my $result_source = $schema->source('FooBar');
> $result_source->has_many(something => 'ExampleApp::Wotsits');
> 
> 
> Or perhaps this?
> my $schema = ExampleApp->connect(..);
> my $class = $schema->class('FooBar');
> $class->has_many(something => 'ExampleApp::Wotsits');
> 
> 
> I have my suspicions that neither are correct though.

PS. Assume the has_many() call is correct though, eg. if I had written
->has_many(something => 'ExampleApp::Wotsits', 'foobar');
rather than the incorrect version above.



More information about the DBIx-Class mailing list