Commit | Line | Data |
4f4fd192 |
1 | use MooseX::Declare; |
2 | class SQL::Translator::Object::Column { |
70ada8ac |
3 | use MooseX::Types::Moose qw(ArrayRef Bool HashRef Int Maybe Str); |
f49a2a49 |
4 | use MooseX::MultiMethods; |
5 | use SQL::Translator::Types qw(ColumnSize Constraint Table Trigger); |
4f4fd192 |
6 | extends 'SQL::Translator::Object'; |
f49a2a49 |
7 | |
8 | has 'table' => ( |
9 | is => 'rw', |
10 | isa => Table, |
11 | required => 1, |
12 | weak_ref => 1, |
13 | ); |
4f4fd192 |
14 | |
15 | has 'name' => ( |
16 | is => 'rw', |
17 | isa => Str, |
18 | required => 1 |
19 | ); |
20 | |
21 | has 'data_type' => ( |
22 | is => 'rw', |
81429cb9 |
23 | isa => Str, |
24 | required => 1 |
25 | ); |
26 | |
27 | has 'sql_data_type' => ( |
28 | is => 'rw', |
4f4fd192 |
29 | isa => Int, |
30 | required => 1 |
31 | ); |
32 | |
33 | has 'size' => ( |
34 | is => 'rw', |
70ada8ac |
35 | isa => ColumnSize, |
36 | coerce => 1, |
37 | auto_deref => 1, |
4f4fd192 |
38 | ); |
39 | |
40 | has 'is_nullable' => ( |
41 | is => 'rw', |
42 | isa => Bool, |
43 | required => 1, |
44 | default => 1 |
45 | ); |
46 | |
4f4fd192 |
47 | has 'default_value' => ( |
48 | is => 'rw', |
49 | isa => Maybe[Str], |
50 | ); |
0874db2d |
51 | |
81429cb9 |
52 | has 'is_auto_increment' => ( |
53 | is => 'rw', |
54 | isa => Bool, |
55 | required => 1, |
56 | default => 0 |
57 | ); |
58 | |
0874db2d |
59 | has 'is_primary_key' => ( |
60 | is => 'rw', |
61 | isa => Bool, |
62 | default => 0 |
63 | ); |
70ada8ac |
64 | |
65 | has 'is_foreign_key' => ( |
66 | is => 'rw', |
67 | isa => Bool, |
68 | default => 0 |
69 | ); |
70 | |
71 | has 'foreign_key_reference' => ( |
72 | is => 'rw', |
73 | isa => Constraint, |
74 | ); |
4f4fd192 |
75 | |
76 | has 'trigger' => ( |
77 | is => 'rw', |
78 | isa => Trigger, |
79 | ); |
0874db2d |
80 | |
81 | has 'extra' => ( |
82 | is => 'rw', |
83 | isa => HashRef, |
84 | auto_deref => 1, |
85 | ); |
70ada8ac |
86 | |
87 | around size(@args) { |
88 | $self->$orig(@args) if @args; |
89 | my @sizes = $self->$orig; |
90 | return wantarray ? @sizes |
91 | : join ',', @sizes; |
92 | } |
b750d2f1 |
93 | |
94 | method order { } |
95 | method is_unique { } |
4f4fd192 |
96 | } |