Commit | Line | Data |
18fca96a |
1 | package DBIx::Class::Schema::Loader::Writing; |
a78e3fed |
2 | |
3 | # Empty. POD only. |
4 | |
5 | 1; |
6 | |
7 | =head1 NAME |
8 | |
18fca96a |
9 | DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide |
a78e3fed |
10 | |
11 | =head1 SYNOPSIS |
12 | |
18fca96a |
13 | package DBIx::Class::Schema::Loader::Foo; |
a78e3fed |
14 | |
15 | # THIS IS JUST A TEMPLATE TO GET YOU STARTED. |
16 | |
17 | use strict; |
3980d69c |
18 | use warnings; |
2a4b8262 |
19 | use Class::C3; |
18fca96a |
20 | use base 'DBIx::Class::Schema::Loader::Generic'; |
a78e3fed |
21 | |
3980d69c |
22 | sub _db_classes { |
a78e3fed |
23 | return qw/DBIx::Class::PK::Auto::Foo/; |
24 | # You may want to return more, or less, than this. |
25 | } |
26 | |
3980d69c |
27 | sub _tables { |
28 | my $self = shift; |
29 | my $dbh = $self->schema->storage->dbh; |
a78e3fed |
30 | return $dbh->tables; # Your DBD may need something different |
31 | } |
32 | |
3980d69c |
33 | sub _table_info { |
34 | my ( $self, $table ) = @_; |
a78e3fed |
35 | ... |
36 | return ( \@cols, \@primary ); |
37 | } |
38 | |
3980d69c |
39 | sub _load_relationships { |
40 | my $self = shift; |
a78e3fed |
41 | ... |
3980d69c |
42 | |
43 | # make a simple relationship, where $table($column) |
44 | # references the PK of $f_table: |
45 | $self->_make_simple_rel($table, $f_table, $column); |
46 | |
47 | # make a relationship with a complex condition-clause: |
48 | $self->_make_cond_rel($table, $f_table, |
49 | { foo => bar, baz => xaa } ); |
50 | |
a78e3fed |
51 | ... |
52 | } |
53 | |
54 | =cut |