- Refactored some, moved more stuff over to using get/store column instead of direct...
[dbsrgits/DBIx-Class.git] / t / testlib / Log.pm
CommitLineData
ea2e61bf 1package Log;
2
3BEGIN { unshift @INC, './t/testlib'; }
4use base 'MyBase';
5
6use strict;
7use Time::Piece::MySQL;
8use POSIX;
9
10__PACKAGE__->set_table();
11__PACKAGE__->columns(All => qw/id message datetime_stamp/);
12__PACKAGE__->has_a(
13 datetime_stamp => 'Time::Piece',
14 inflate => 'from_mysql_datetime',
15 deflate => 'mysql_datetime'
16);
17
18__PACKAGE__->add_trigger(before_create => \&set_dts);
19__PACKAGE__->add_trigger(before_update => \&set_dts);
20
21sub set_dts {
22 shift->datetime_stamp(
23 POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime(time)));
24}
25
26sub create_sql {
27 return qq{
28 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
29 message VARCHAR(255),
30 datetime_stamp DATETIME
31 };
32}
33
341;
35