line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Schema::DSL::Context; |
2
|
8
|
|
|
8
|
|
230
|
use 5.008_001; |
|
8
|
|
|
|
|
23
|
|
3
|
8
|
|
|
8
|
|
43
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
200
|
|
4
|
8
|
|
|
8
|
|
41
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
413
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
5229
|
use Moo; |
|
8
|
|
|
|
|
117385
|
|
|
8
|
|
|
|
|
126
|
|
7
|
8
|
|
|
8
|
|
18298
|
use Clone qw/clone/; |
|
8
|
|
|
|
|
22140
|
|
|
8
|
|
|
|
|
608
|
|
8
|
8
|
|
|
8
|
|
5855
|
use SQL::Translator; |
|
8
|
|
|
|
|
2160518
|
|
|
8
|
|
|
|
|
3309
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has name => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has db => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
default => sub {'MySQL'}, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has translator => ( |
20
|
|
|
|
|
|
|
is => 'lazy', |
21
|
|
|
|
|
|
|
default => sub { |
22
|
|
|
|
|
|
|
SQL::Translator->new; |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has schema => ( |
27
|
|
|
|
|
|
|
is => 'lazy', |
28
|
|
|
|
|
|
|
default => sub { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
$self->translator->schema->name($self->name); |
31
|
|
|
|
|
|
|
$self->translator->schema->database($self->db); |
32
|
|
|
|
|
|
|
$self->translator->schema; |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has _creating_table => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
clearer => '_clear_creating_table', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has translate => ( |
42
|
|
|
|
|
|
|
is => 'lazy', |
43
|
|
|
|
|
|
|
default => sub { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
my $output = $self->translator->translate(to => $self->db); |
46
|
|
|
|
|
|
|
# ignore initial comments. |
47
|
|
|
|
|
|
|
1 while $output =~ s/\A--.*?\r?\n//ms; |
48
|
|
|
|
|
|
|
$output; |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has table_extra => ( |
53
|
|
|
|
|
|
|
is => 'lazy', |
54
|
|
|
|
|
|
|
writer => 'set_table_extra', |
55
|
|
|
|
|
|
|
default => sub { |
56
|
|
|
|
|
|
|
shift->db eq 'MySQL' ? { |
57
|
|
|
|
|
|
|
mysql_table_type => 'InnoDB', |
58
|
|
|
|
|
|
|
mysql_charset => 'utf8', |
59
|
|
|
|
|
|
|
} : {}; |
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has default_unsigned => ( |
64
|
|
|
|
|
|
|
is => 'rw', |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has default_not_null => ( |
68
|
|
|
|
|
|
|
is => 'rw', |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has no_fk_translator => ( |
72
|
|
|
|
|
|
|
is => 'lazy', |
73
|
|
|
|
|
|
|
default => sub { |
74
|
|
|
|
|
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
my $no_fk_translator = clone $self->translator; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
for my $table ($no_fk_translator->schema->get_tables) { |
78
|
|
|
|
|
|
|
$table->drop_constraint($_) for $table->fkey_constraints; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$no_fk_translator; |
82
|
|
|
|
|
|
|
}, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has no_fk_translate => ( |
86
|
|
|
|
|
|
|
is => 'lazy', |
87
|
|
|
|
|
|
|
default => sub { |
88
|
|
|
|
|
|
|
my $self = shift; |
89
|
|
|
|
|
|
|
my $output = $self->no_fk_translator->translate(to => $self->db); |
90
|
|
|
|
|
|
|
# ignore initial comments. |
91
|
|
|
|
|
|
|
1 while $output =~ s/\A--.*?\r?\n//ms; |
92
|
|
|
|
|
|
|
$output; |
93
|
|
|
|
|
|
|
}, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
has default_varchar_size => ( |
97
|
|
|
|
|
|
|
is => 'rw', |
98
|
|
|
|
|
|
|
default => sub { 255 }, |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
|
101
|
8
|
|
|
8
|
|
65
|
no Moo; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
66
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _creating_table_name { |
104
|
|
|
|
|
|
|
shift->_creating_table->{table_name} |
105
|
2
|
50
|
|
2
|
|
20
|
or die 'Not in create_table block.'; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |