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