| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geoffrey::Write; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
587
|
use utf8; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
18
|
|
|
4
|
3
|
|
|
3
|
|
120
|
use 5.016; |
|
|
3
|
|
|
|
|
9
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
113
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
177
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$Geoffrey::Write::VERSION = '0.000203'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
18
|
use parent 'Geoffrey::Role::Core'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
3
|
|
|
3
|
1
|
45
|
my $class = shift; |
|
14
|
3
|
|
|
|
|
19
|
my $self = $class->SUPER::new(@_); |
|
15
|
|
|
|
|
|
|
$self->{changelog_types} = [ |
|
16
|
3
|
|
|
|
|
19
|
qw/sequences tables primaries uniques |
|
17
|
|
|
|
|
|
|
foreigns indexes views functions triggers/ |
|
18
|
|
|
|
|
|
|
]; |
|
19
|
3
|
|
|
|
|
13
|
return bless $self, $class; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
21
|
|
100
|
21
|
1
|
190
|
sub author { return $_[0]->{author} // 'Mario Zieschang'; } |
|
23
|
20
|
|
50
|
20
|
1
|
128
|
sub changeset_key { return $_[0]->{changeset_key} // 'maz'; } |
|
24
|
13
|
|
|
13
|
1
|
1563
|
sub inc_changelog_count { return $_[0]->{changelog_count}++; } |
|
25
|
34
|
|
100
|
34
|
1
|
80
|
sub changelog_count { $_[0]->{changelog_count} //= 0; return $_[0]->{changelog_count}; } |
|
|
34
|
|
|
|
|
235
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub changeset_id { |
|
28
|
20
|
|
|
20
|
1
|
41
|
my ($self, $i_count) = @_; |
|
29
|
20
|
100
|
|
|
|
41
|
return join q/-/, $self->changelog_count, $i_count ? $i_count : 1, $self->changeset_key; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub changeset { |
|
33
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
|
34
|
1
|
50
|
|
|
|
5
|
return $self->{changeset} if ($self->{changeset}); |
|
35
|
1
|
|
|
|
|
7
|
require Geoffrey::Changeset; |
|
36
|
1
|
|
|
|
|
6
|
$self->{changeset} = Geoffrey::Changeset->new(converter => $self->converter, dbh => $self->dbh,); |
|
37
|
1
|
|
|
|
|
9
|
return $self->{changeset}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub run { |
|
41
|
1
|
|
|
1
|
1
|
4
|
my ($self, $s_dir, $s_schema, $b_dump) = @_; |
|
42
|
1
|
|
|
|
|
5
|
my $o_changelog_io = $self->changelog_io; |
|
43
|
|
|
|
|
|
|
# if changelog_io needs a dbh it must store the changelogs into a database |
|
44
|
|
|
|
|
|
|
# and not in a filepath |
|
45
|
1
|
50
|
|
|
|
4
|
if ($o_changelog_io->needs_dbh) { |
|
46
|
0
|
|
|
|
|
0
|
$s_dir = q~changelog-~; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
else { |
|
49
|
1
|
|
|
|
|
4
|
require File::Path; |
|
50
|
1
|
|
|
|
|
74
|
File::Path::make_path($s_dir); |
|
51
|
1
|
|
|
|
|
4
|
$s_dir = $s_dir . q~/changelog-~; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
my @a_changelogs = (); |
|
55
|
1
|
|
|
|
|
3
|
for (@{$self->{changelog_types}}) { |
|
|
1
|
|
|
|
|
5
|
|
|
56
|
9
|
100
|
|
|
|
17
|
my $ar_data = eval { return $self->$_($s_schema, 1); } or do { next; }; |
|
|
9
|
|
|
|
|
102
|
|
|
|
6
|
|
|
|
|
8948
|
|
|
57
|
3
|
50
|
|
|
|
7
|
next if scalar @{$ar_data} == 0; |
|
|
3
|
|
|
|
|
8
|
|
|
58
|
3
|
|
|
|
|
9
|
my $s_file = $s_dir . $self->inc_changelog_count . q/-/ . $_; |
|
59
|
3
|
|
|
|
|
13
|
$o_changelog_io->write($s_file, $ar_data, $b_dump); |
|
60
|
3
|
|
|
|
|
10
|
push @a_changelogs, $self->changelog_count . q/-/ . $_; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
1
|
|
|
|
|
9
|
return $o_changelog_io->write($s_dir . q~/changelog~, {changelogs => \@a_changelogs}, $b_dump); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub sequences { |
|
66
|
2
|
|
|
2
|
1
|
8
|
my ($self, $s_schema) = @_; |
|
67
|
2
|
|
|
|
|
1107
|
require Geoffrey::Action::Constraint::Default; |
|
68
|
|
|
|
|
|
|
return [{ |
|
69
|
2
|
|
|
|
|
12
|
id => $self->changeset_id, |
|
70
|
|
|
|
|
|
|
author => $self->author, |
|
71
|
|
|
|
|
|
|
entries => |
|
72
|
|
|
|
|
|
|
Geoffrey::Action::Constraint::Default->new(dbh => $self->dbh, converter => $self->converter) |
|
73
|
|
|
|
|
|
|
->list_from_schema($s_schema)}]; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub tables { |
|
77
|
2
|
|
|
2
|
1
|
8
|
my ($self, $s_schema, $include_columns) = @_; |
|
78
|
2
|
|
|
|
|
20
|
my $count = 1; |
|
79
|
2
|
|
|
|
|
12
|
require Geoffrey::Action::Table; |
|
80
|
2
|
|
|
|
|
11
|
my $o_tables = Geoffrey::Action::Table->new(dbh => $self->dbh, converter => $self->converter); |
|
81
|
|
|
|
|
|
|
|
|
82
|
9
|
|
|
|
|
28
|
return [map { $self->map_entry([{action => 'table.add', name => $_}], $count++) } |
|
83
|
2
|
100
|
|
|
|
10
|
@{$o_tables->list_from_schema($s_schema)}] |
|
|
1
|
|
|
|
|
6
|
|
|
84
|
|
|
|
|
|
|
if !$include_columns; |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
6
|
require Geoffrey::Action::Column; |
|
87
|
1
|
|
|
|
|
4
|
my $o_columns = Geoffrey::Action::Column->new(dbh => $self->dbh, converter => $self->converter); |
|
88
|
|
|
|
|
|
|
return [ |
|
89
|
|
|
|
|
|
|
map { |
|
90
|
1
|
|
|
|
|
8
|
$self->map_entry([{ |
|
91
|
|
|
|
|
|
|
action => 'table.add', |
|
92
|
|
|
|
|
|
|
name => $_, |
|
93
|
|
|
|
|
|
|
columns => $o_columns->list_from_schema($s_schema, $_)} |
|
94
|
|
|
|
|
|
|
], |
|
95
|
|
|
|
|
|
|
$count++ |
|
96
|
|
|
|
|
|
|
) |
|
97
|
1
|
|
|
|
|
4
|
} @{$o_tables->list_from_schema($s_schema)}]; |
|
|
1
|
|
|
|
|
7
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub primaries { |
|
101
|
2
|
|
|
2
|
1
|
8
|
my ($self, $s_schema) = @_; |
|
102
|
2
|
|
|
|
|
593
|
require Geoffrey::Action::Constraint::PrimaryKey; |
|
103
|
|
|
|
|
|
|
return [ |
|
104
|
2
|
|
|
|
|
14
|
$self->map_entry( |
|
105
|
|
|
|
|
|
|
Geoffrey::Action::Constraint::PrimaryKey->new(dbh => $self->dbh, converter => $self->converter) |
|
106
|
|
|
|
|
|
|
->list_from_schema($s_schema))]; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub uniques { |
|
110
|
2
|
|
|
2
|
1
|
7
|
my ($self, $s_schema) = @_; |
|
111
|
2
|
|
|
|
|
574
|
require Geoffrey::Action::Constraint::Unique; |
|
112
|
|
|
|
|
|
|
return [ |
|
113
|
2
|
|
|
|
|
12
|
$self->map_entry( |
|
114
|
|
|
|
|
|
|
Geoffrey::Action::Constraint::Unique->new(dbh => $self->dbh, converter => $self->converter) |
|
115
|
|
|
|
|
|
|
->list_from_schema($s_schema))]; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub foreigns { |
|
119
|
2
|
|
|
2
|
1
|
7
|
my ($self, $s_schema) = @_; |
|
120
|
2
|
|
|
|
|
5
|
my $count = 1; |
|
121
|
2
|
|
|
|
|
595
|
require Geoffrey::Action::Constraint::ForeignKey; |
|
122
|
2
|
|
|
|
|
11
|
my $o_foreign_keys |
|
123
|
|
|
|
|
|
|
= Geoffrey::Action::Constraint::ForeignKey->new(dbh => $self->dbh, converter => $self->converter); |
|
124
|
2
|
|
|
|
|
5
|
return [map { $self->map_entry([$_], $count++) } @{$o_foreign_keys->list_from_schema($s_schema)}]; |
|
|
0
|
|
|
|
|
0
|
|
|
|
2
|
|
|
|
|
11
|
|
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub indexes { |
|
128
|
2
|
|
|
2
|
1
|
8
|
my ($self, $s_schema) = @_; |
|
129
|
2
|
|
|
|
|
597
|
require Geoffrey::Action::Constraint::Index; |
|
130
|
|
|
|
|
|
|
return [ |
|
131
|
2
|
|
|
|
|
104
|
$self->map_entry( |
|
132
|
|
|
|
|
|
|
Geoffrey::Action::Constraint::Index->new(converter => $self->converter, dbh => $self->dbh) |
|
133
|
|
|
|
|
|
|
->list_from_schema($s_schema))]; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub views { |
|
137
|
2
|
|
|
2
|
1
|
7
|
my ($self, $s_schema) = @_; |
|
138
|
2
|
|
|
|
|
990
|
require Geoffrey::Action::View; |
|
139
|
|
|
|
|
|
|
return [ |
|
140
|
2
|
|
|
|
|
14
|
$self->map_entry( |
|
141
|
|
|
|
|
|
|
Geoffrey::Action::View->new(converter => $self->converter, dbh => $self->dbh) |
|
142
|
|
|
|
|
|
|
->list_from_schema($s_schema), |
|
143
|
|
|
|
|
|
|
1 |
|
144
|
|
|
|
|
|
|
)]; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub functions { |
|
148
|
3
|
|
|
3
|
1
|
8
|
my ($self, $s_schema) = @_; |
|
149
|
3
|
|
|
|
|
7
|
my $count = 1; |
|
150
|
3
|
|
|
|
|
1364
|
require Geoffrey::Action::Function; |
|
151
|
3
|
|
|
|
|
17
|
my $o_functions = Geoffrey::Action::Function->new(dbh => $self->dbh, converter => $self->converter); |
|
152
|
3
|
|
|
|
|
11
|
return [map { $self->map_entry([$_], $count++) } @{$o_functions->list($s_schema)}]; |
|
|
2
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
11
|
|
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub triggers { |
|
156
|
3
|
|
|
3
|
1
|
336
|
my ($self, $s_schema) = @_; |
|
157
|
3
|
|
|
|
|
7
|
my $count = 1; |
|
158
|
3
|
|
|
|
|
1429
|
require Geoffrey::Action::Trigger; |
|
159
|
3
|
|
|
|
|
24
|
my $o_trigger = Geoffrey::Action::Trigger->new(dbh => $self->dbh, converter => $self->converter); |
|
160
|
3
|
|
|
|
|
9
|
return [map { $self->map_entry([$_], $count++) } @{$o_trigger->list($s_schema)}]; |
|
|
2
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
11
|
|
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub map_entry { |
|
164
|
18
|
|
|
18
|
1
|
38
|
my ($self, $ar_entries, $i_count) = @_; |
|
165
|
18
|
|
|
|
|
39
|
return {id => $self->changeset_id($i_count), author => $self->author, entries => $ar_entries,}; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; # End of Geoffrey::Read |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
__END__ |