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