line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Schema::Changelog::Driver; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBIx::Schema::Changelog::Driver - Abstract driver class. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.8.0 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.8.0'; |
14
|
|
|
|
|
|
|
|
15
|
9
|
|
|
9
|
|
12490
|
use utf8; |
|
9
|
|
|
|
|
114
|
|
|
9
|
|
|
|
|
80
|
|
16
|
9
|
|
|
9
|
|
416
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
499
|
|
17
|
9
|
|
|
9
|
|
60
|
use warnings FATAL => 'all'; |
|
9
|
|
|
|
|
74
|
|
|
9
|
|
|
|
|
536
|
|
18
|
9
|
|
|
9
|
|
55
|
use Moose::Role; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
86
|
|
19
|
9
|
|
|
9
|
|
49636
|
use MooseX::Types::PerlVersion qw( PerlVersion ); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
109
|
|
20
|
9
|
|
|
9
|
|
9413
|
use MooseX::Types::Moose qw( Maybe Undef ); |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
74
|
|
21
|
9
|
|
|
9
|
|
55826
|
use Data::Dumper; |
|
9
|
|
|
|
|
41800
|
|
|
9
|
|
|
|
|
7589
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has min_version => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => PerlVersion, |
26
|
|
|
|
|
|
|
coerce => 1, |
27
|
|
|
|
|
|
|
builder => '_min_version', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has max_version => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => PerlVersion | Undef, |
33
|
|
|
|
|
|
|
coerce => 1, |
34
|
|
|
|
|
|
|
builder => '_max_version', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has changelog_table => ( |
38
|
|
|
|
|
|
|
isa => 'ArrayRef[Any]', |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
default => sub { |
41
|
|
|
|
|
|
|
return [ |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
name => 'id', |
44
|
|
|
|
|
|
|
type => 'varchar', |
45
|
|
|
|
|
|
|
lenght => 255, |
46
|
|
|
|
|
|
|
primarykey => 1, |
47
|
|
|
|
|
|
|
notnull => 1, |
48
|
|
|
|
|
|
|
default => '\'\'' |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
name => 'author', |
52
|
|
|
|
|
|
|
type => 'varchar', |
53
|
|
|
|
|
|
|
lenght => 255, |
54
|
|
|
|
|
|
|
notnull => 1, |
55
|
|
|
|
|
|
|
default => '\'\'' |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
name => 'filename', |
59
|
|
|
|
|
|
|
type => 'varchar', |
60
|
|
|
|
|
|
|
lenght => 255, |
61
|
|
|
|
|
|
|
notnull => 1, |
62
|
|
|
|
|
|
|
default => '\'\'' |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
name => 'flag', |
66
|
|
|
|
|
|
|
type => 'timestamp', |
67
|
|
|
|
|
|
|
notnull => 1, |
68
|
|
|
|
|
|
|
default => 'current' |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
name => 'orderexecuted', |
72
|
|
|
|
|
|
|
type => 'varchar', |
73
|
|
|
|
|
|
|
lenght => 255, |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
name => 'md5sum', |
77
|
|
|
|
|
|
|
type => 'varchar', |
78
|
|
|
|
|
|
|
lenght => 255, |
79
|
|
|
|
|
|
|
notnull => 1, |
80
|
|
|
|
|
|
|
default => '\'\'' |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
name => 'description', |
84
|
|
|
|
|
|
|
type => 'varchar', |
85
|
|
|
|
|
|
|
lenght => 255, |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
name => 'comments', |
89
|
|
|
|
|
|
|
type => 'varchar', |
90
|
|
|
|
|
|
|
lenght => 255, |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
name => 'changelog', |
94
|
|
|
|
|
|
|
type => 'varchar', |
95
|
|
|
|
|
|
|
lenght => 10, |
96
|
|
|
|
|
|
|
notnull => 1, |
97
|
|
|
|
|
|
|
default => '\'\'' |
98
|
|
|
|
|
|
|
}, |
99
|
|
|
|
|
|
|
]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has origin_types => ( |
104
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
105
|
|
|
|
|
|
|
is => 'ro', |
106
|
|
|
|
|
|
|
default => sub { |
107
|
|
|
|
|
|
|
return [ |
108
|
|
|
|
|
|
|
'abstime', 'aclitem', #A |
109
|
|
|
|
|
|
|
'bigint', 'bigserial', 'bit', 'varbit', 'blob', 'bool', 'box', |
110
|
|
|
|
|
|
|
'bytea', #B |
111
|
|
|
|
|
|
|
'char', 'character', 'varchar', 'cid', 'cidr', 'circle', #C |
112
|
|
|
|
|
|
|
'date', 'daterange', 'double', 'double_precision', 'decimal', #D |
113
|
|
|
|
|
|
|
#E |
114
|
|
|
|
|
|
|
#F |
115
|
|
|
|
|
|
|
'gtsvector', #G |
116
|
|
|
|
|
|
|
#H |
117
|
|
|
|
|
|
|
'inet', 'int2vector', 'int4range', 'int8range', 'integer', |
118
|
|
|
|
|
|
|
'interval', #I |
119
|
|
|
|
|
|
|
'json', #J |
120
|
|
|
|
|
|
|
#K |
121
|
|
|
|
|
|
|
'line', 'lseg', #L |
122
|
|
|
|
|
|
|
'macaddr', 'money', #M |
123
|
|
|
|
|
|
|
'name', 'numeric', 'numrange', #N |
124
|
|
|
|
|
|
|
'oid', 'oidvector', #O |
125
|
|
|
|
|
|
|
'path', 'pg_node_tree', 'point', 'polygon', #P |
126
|
|
|
|
|
|
|
#Q |
127
|
|
|
|
|
|
|
'real', 'refcursor', 'regclass', 'regconfig', 'regdictionary', |
128
|
|
|
|
|
|
|
'regoper', 'regoperator', 'regproc', 'regprocedure', 'regtype', |
129
|
|
|
|
|
|
|
'reltime', #R |
130
|
|
|
|
|
|
|
'serial', 'smallint', 'smallserial', 'smgr', #S |
131
|
|
|
|
|
|
|
'text', 'tid', 'timestamp', 'timestamp_tz', 'time', 'time_tz', |
132
|
|
|
|
|
|
|
'tinterval', 'tsquery', 'tsrange', 'tstzrange', 'tsvector', |
133
|
|
|
|
|
|
|
'txid_snapshot', #T |
134
|
|
|
|
|
|
|
'uuid', #U |
135
|
|
|
|
|
|
|
#V |
136
|
|
|
|
|
|
|
#W |
137
|
|
|
|
|
|
|
'xid', #X |
138
|
|
|
|
|
|
|
#Y |
139
|
|
|
|
|
|
|
#Z |
140
|
|
|
|
|
|
|
]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over 4 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item check_version |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub check_version { |
153
|
8
|
|
|
8
|
1
|
1330
|
my ( $self, $vers ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
8
|
100
|
|
|
|
35
|
if ( $self->has_max_version ) { |
156
|
3
|
100
|
100
|
|
|
227
|
return 1 |
157
|
|
|
|
|
|
|
if ( $self->min_version() <= $vers && $vers <= $self->max_version() ); |
158
|
2
|
|
|
|
|
641
|
die "Unsupported version: " |
159
|
|
|
|
|
|
|
. $self->min_version() |
160
|
|
|
|
|
|
|
. " <= $vers <= " |
161
|
|
|
|
|
|
|
. $self->max_version(); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
else { |
164
|
5
|
100
|
|
|
|
280
|
return 1 if ( $self->min_version() <= $vers ); |
165
|
1
|
|
|
|
|
226
|
die "Unsupported version: " . $self->min_version() . " <= $vers"; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item type |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub type { |
174
|
108
|
|
|
108
|
1
|
183
|
my ( $self, $col ) = @_; |
175
|
108
|
|
|
|
|
4686
|
my $ret = |
176
|
108
|
50
|
|
|
|
127
|
( grep( /^$col->{type}$/, @{ $self->origin_types() } ) ) |
177
|
|
|
|
|
|
|
? $self->types()->{ $col->{type} } |
178
|
|
|
|
|
|
|
: undef; |
179
|
107
|
50
|
|
|
|
264
|
die "Type: $col->{type} not found.\n" unless $ret; |
180
|
107
|
50
|
|
|
|
420
|
$ret .= ( $col->{strict} ) ? '(strict)' : ''; |
181
|
107
|
100
|
|
|
|
306
|
$ret .= ( defined $col->{lenght} ) ? "($col->{lenght})" : ''; |
182
|
107
|
|
|
|
|
390
|
return $ret; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item has_max_version |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
check if max version is set |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
8
|
|
|
8
|
1
|
474
|
sub has_max_version { defined shift->max_version } |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item has_max_version |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
builder for max version |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
9
|
|
|
9
|
|
394
|
sub _max_version { } |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item create_changelog_table |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub create_changelog_table { |
206
|
2
|
|
|
2
|
1
|
11
|
my ( $self, $dbh, $name ) = @_; |
207
|
2
|
|
|
|
|
95
|
my $sth = $dbh->prepare( $self->select_changelog_table() ); |
208
|
2
|
50
|
50
|
|
|
1159
|
if ( $sth->execute() or die "Some error $!" ) { |
209
|
2
|
|
|
|
|
26
|
foreach ( $sth->fetchrow_array() ) { |
210
|
0
|
0
|
|
|
|
0
|
return undef if ( $_ =~ /^$name$/ ); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
return { |
214
|
2
|
|
|
|
|
118
|
name => $name, |
215
|
|
|
|
|
|
|
columns => $self->changelog_table() |
216
|
|
|
|
|
|
|
}; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; # End of DBIx::Schema::Changelog::Driver |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
__END__ |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=back |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 AUTHOR |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Mario Zieschang, C<< <mario.zieschang at combase.de> >> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Copyright 2015 Mario Zieschang. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
234
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
235
|
|
|
|
|
|
|
copy of the full license at: |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
240
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
241
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
242
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
245
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
246
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
249
|
|
|
|
|
|
|
mark, trade name, or logo of the Copyright Holder. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
252
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
253
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
254
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
255
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
256
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
257
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
258
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
261
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
262
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR |
263
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
264
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
265
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
266
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
267
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |