about summary refs log tree commit diff
path: root/lib/jitterbug/Schema/Result/Task.pm
blob: 2eaed626ef58ab17e95a3b277c959066fe0f7b70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package jitterbug::Schema::Result::Task;
use base qw/DBIx::Class::Core/;

__PACKAGE__->table('task');
__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
__PACKAGE__->add_columns(
    taskid => {
        data_type         => 'int',
        is_auto_increment => 1,
    },
    sha256    => { data_type => 'text', is_foreign_key => 1 },
    projectid => {
        data_type      => 'int',
        is_foreign_key => 1,
    },
    running => {
        data_type     => 'bool',
        default_value => 0,
    },
    started_when => {
        data_type                 => 'datetime',
        is_nullable               => 1,
        datetime_undef_if_invalid => 1
    },
);

__PACKAGE__->set_primary_key('taskid');
__PACKAGE__->add_unique_constraint( [qw/projectid/] );
__PACKAGE__->add_unique_constraint( [qw/sha256/] );
__PACKAGE__->belongs_to(
    project => 'jitterbug::Schema::Result::Project',
    'projectid'
);
__PACKAGE__->belongs_to(
    commit => 'jitterbug::Schema::Result::Commit',
    'sha256'
);

1;