RT56175: allow tables to have a prefix
[dbsrgits/DBIx-Class-Journal.git] / lib / DBIx / Class / Schema / Journal / DB / ChangeSet.pm
1 package DBIx::Class::Schema::Journal::DB::ChangeSet;
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/InflateColumn::DateTime/);
9     $class->table($prefix . 'changeset');
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         user_id => {
19                 data_type => 'integer',
20                 is_nullable => 1,
21                 is_foreign_key => 1,
22         },
23         set_date => {
24                 data_type => 'timestamp',
25                 is_nullable => 0,
26         },
27         session_id => {
28                 data_type => 'varchar',
29                 size => 255,
30                 is_nullable => 1,
31         },
32     );
33     
34     $class->set_primary_key('ID');
35 }
36
37 sub new {
38     my $self = shift->next::method(@_);
39     # I think we should not do the following and
40     # instead use DBIx::Class::TimeStamp.  If I
41     # can think of a good way (passing a version on
42     # import?) to do it and retain backcompat I will.
43     #
44     # --fREW, 01-27-2010
45     $self->set_date(gmtime);
46     return $self;
47 }
48
49 1;