From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide

SYNOPSIS

# THIS IS JUST A TEMPLATE TO GET YOU STARTED.
use strict;
sub _db_classes {
return qw/DBIx::Class::PK::Auto::Foo/;
# You may want to return more, or less, than this.
}
sub _tables {
my $self = shift;
my $dbh = $self->schema->storage->dbh;
return $dbh->tables; # Your DBD may need something different
}
sub _table_info {
my ( $self, $table ) = @_;
...
return ( \@cols, \@primary );
}
sub _load_relationships {
my $self = shift;
...
# make a simple relationship, where $table($column)
# references the PK of $f_table:
$self->_make_simple_rel($table, $f_table, $column);
# make a relationship with a complex condition-clause:
$self->_make_cond_rel($table, $f_table,
{ foo => bar, baz => xaa } );
...
}