blib/lib/QBit/Application/Model/DB/mysql/Table/MultistateActionLog.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 46 CC 3 SCAR 13.9
CC
3
Cov
0%
default_fields
6.0
default_indexes
6.0
default_primary_key
2.0
CRAP 4.0
1 package QBit::Application::Model::DB::mysql::Table::MultistateActionLog;
2 $QBit::Application::Model::DB::mysql::Table::MultistateActionLog::VERSION = '0.002';
3 use qbit;
4  
5 use base qw(QBit::Application::Model::DB::mysql::Table);
6  
7 sub default_fields {
8 my ($package, %opts) = @_;
9  
10 return (
11 {name => 'id', type => 'BIGINT', unsigned => TRUE, not_null => TRUE, autoincrement => TRUE},
12 {name => 'dt', type => 'DATETIME', not_null => TRUE},
13 {name => 'user_id'},
14 (map {{name => "elem_$_", not_null => TRUE}} @{$opts{'elem_table_pk'}}),
15 {name => 'old_multistate', type => 'BIGINT', unsigned => TRUE, not_null => TRUE},
16 {name => 'action', type => 'VARCHAR', length => 100, not_null => TRUE},
17 {name => 'new_multistate', type => 'BIGINT', unsigned => TRUE, not_null => TRUE},
18 ($opts{'with_opts'} ? {name => 'opts', type => 'TEXT', not_null => TRUE} : ()),
19 {name => 'comment', type => 'VARCHAR', length => 100, not_null => TRUE, default => ''},
20 );
21 }
22  
23 sub default_primary_key {
24 return ['id'];
25 }
26  
27 sub default_indexes {
28 my ($package, %opts) = @_;
29 my @elems = $opts{'elem_table_pk'} ? map("elem_$_", @{$opts{'elem_table_pk'}}) : 'elem_id';
30 return ({fields => ['dt', @elems, 'action']}, {fields => [@elems, 'action']});
31 }
32  
33 sub default_foreign_keys {
34 my ($package, %opts) = @_;
35  
36 return (
37 [['user_id'] => users => ['id']],
38 [[map {"elem_$_"} @{$opts{'elem_table_pk'}}] => $opts{'elem_table'} => $opts{'elem_table_pk'}],
39 );
40 }
41  
42 TRUE;
43  
44 __END__