Revision 9c1cb5f8
Von Tamino Steinert vor 9 Monaten hinzugefügt
sql/Pg-upgrade2/add_file_version.pl | ||
---|---|---|
19 | 19 |
my ($self) = @_; |
20 | 20 |
|
21 | 21 |
SL::DB->client->with_transaction(sub { |
22 |
my @errors; |
|
22 | 23 |
my $all_dbfiles = SL::DB::Manager::File->get_all; |
23 | 24 |
foreach my $dbfile (@$all_dbfiles) { |
24 | 25 |
my $file_id = $dbfile->id; |
... | ... | |
36 | 37 |
|
37 | 38 |
my @versions = SL::File->get_all_versions(dbfile => $dbfile); |
38 | 39 |
foreach my $version (@versions) { |
39 |
my $tofile = $version->get_file(); |
|
40 |
my $tofile; |
|
41 |
eval { |
|
42 |
$tofile = $version->get_file(); |
|
43 |
} or do { |
|
44 |
my @values; |
|
45 |
push @values, $@; # error message |
|
46 |
push @values, $version->file_name; |
|
47 |
push @values, $version->id; |
|
48 |
push @errors, '<td>' . join('</td><td>', @values) . '</td>';; |
|
49 |
next; |
|
50 |
}; |
|
40 | 51 |
my $rel_file = $tofile; |
41 | 52 |
$rel_file =~ s/$doc_path//; |
42 | 53 |
|
... | ... | |
50 | 61 |
)->save; |
51 | 62 |
} |
52 | 63 |
} |
64 |
if (scalar @errors) { |
|
65 |
my $error_message = 'Please resolve the errors by removing invalid database entries or by adding the corresponding files under the expected paths: |
|
66 |
<table class="tbl-list" border="1" style="border-collapse: collapse"> |
|
67 |
<thead><tr> |
|
68 |
<th>error message</th> |
|
69 |
<th>file_name</th> |
|
70 |
<th>file_id</th> |
|
71 |
</tr></thead> |
|
72 |
'; |
|
73 |
$error_message .= '<tr>' . join('</tr><tr>', @errors) . '</tr>'; |
|
74 |
$error_message .= '</table>'; |
|
75 |
die $error_message; |
|
76 |
} |
|
53 | 77 |
1; |
54 | 78 |
}) or do { die SL::DB->client->error }; |
55 | 79 |
|
Auch abrufbar als: Unified diff
FileVersion: Migration: Fehler als Tabelle ausgeben