RT56175: allow tables to have a prefix
[dbsrgits/DBIx-Class-Journal.git] / lib / DBIx / Class / Schema / Journal / DB / ChangeLog.pm
1 package DBIx::Class::Schema::Journal::DB::ChangeLog;
2
3 use base 'DBIx::Class::Core';
4
5 sub journal_define_table {
6     my ( $class, $schema_class, $prefix ) = @_;
7     
8     $class->load_components(qw/Ordered/);
9     $class->table($prefix . 'changelog');
10     
11     $class->add_columns(
12         ID => {
13                 data_type => 'integer',
14                 is_auto_increment => 1,
15                 is_primary_key => 1,
16                 is_nullable => 0,
17         },
18                 changeset_id => {
19                 data_type => 'integer',
20                 is_nullable => 0,
21                 is_foreign_key => 1,
22         },
23         order_in => {
24                 data_type => 'integer',
25                 is_nullable => 0,
26         },
27     );
28     
29     
30     $class->set_primary_key('ID');
31     $class->add_unique_constraint('setorder', [ qw/changeset_id order_in/ ]);
32     $class->belongs_to('changeset', "${schema_class}::ChangeSet", 'changeset_id');
33     
34     $class->position_column('order_in');
35     $class->grouping_column('changeset_id');
36 }
37
38 1;