line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Schema::Changelog::Action::Sequence; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBIx::Schema::Changelog::Action::Sequence - Action handler for sequences |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.8.0 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.8.0'; |
14
|
|
|
|
|
|
|
|
15
|
8
|
|
|
8
|
|
51
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
405
|
|
16
|
8
|
|
|
8
|
|
50
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
294
|
|
17
|
8
|
|
|
8
|
|
43
|
use Moose; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
61
|
|
18
|
8
|
|
|
8
|
|
63208
|
use Data::Dumper; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
3834
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
with 'DBIx::Schema::Changelog::Action'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item add |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Decides if autoincrement or to create a sequnece. |
29
|
|
|
|
|
|
|
Add sequences if it's needed |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add { |
34
|
13
|
|
|
13
|
1
|
29
|
my ( $self, $params ) = @_; |
35
|
13
|
|
|
|
|
633
|
my $actions = $self->driver()->actions; |
36
|
13
|
|
|
|
|
547
|
my $defaults = $self->driver()->defaults(); |
37
|
13
|
50
|
50
|
|
|
157
|
return $defaults->{ $params->{default} } |
38
|
|
|
|
|
|
|
|| '' |
39
|
|
|
|
|
|
|
if ( $defaults->{ $params->{default} } ne 'sequence' ); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
die "Create sequence is not supported!" |
42
|
|
|
|
|
|
|
unless ( $actions->{create_sequence} ); |
43
|
0
|
|
|
|
|
|
return $self->_create_sequence($params); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item alter |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Not yet implemented! |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
sub alter { } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item drop |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Not yet implemented! |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
1
|
|
sub drop { } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item _create_sequence |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _create_sequence { |
67
|
0
|
|
|
0
|
|
|
my ( $self, $params ) = @_; |
68
|
0
|
|
|
|
|
|
my $actions = $self->driver()->actions; |
69
|
0
|
0
|
|
|
|
|
die "Db connection iss missing!" unless ( $self->dbh() ); |
70
|
0
|
|
|
|
|
|
$params->{table} =~ s/"//g; |
71
|
0
|
|
|
|
|
|
$params->{name} =~ s/"//g; |
72
|
0
|
|
|
|
|
|
my $seq = 'seq_' . $params->{table} . '_' . $params->{name}; |
73
|
0
|
|
|
|
|
|
my $sql = _replace_spare( $actions->{create_sequence}, |
74
|
|
|
|
|
|
|
[ $seq, 1, 1, 9223372036854775807, 1, 1 ] ); |
75
|
0
|
|
|
|
|
|
print __PACKAGE__, __LINE__, Dumper($sql); |
76
|
0
|
|
|
|
|
|
$self->_do($sql); |
77
|
0
|
|
|
|
|
|
return _replace_spare( $actions->{nextval_sequence}, [$seq] ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
8
|
|
|
8
|
|
55
|
no Moose; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
51
|
|
81
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Mario Zieschang, C<< <mario.zieschang at combase.de> >> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Copyright 2015 Mario Zieschang. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
98
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
99
|
|
|
|
|
|
|
copy of the full license at: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
104
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
105
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
106
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
109
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
110
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
113
|
|
|
|
|
|
|
mark, trade name, or logo of the Copyright Holder. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
116
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
117
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
118
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
119
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
120
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
121
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
122
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
125
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
126
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR |
127
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
128
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
129
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
130
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
131
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |