Bug 34869: DBRev 23.06.00.069
[koha.git] / installer / data / mysql / db_revs / 230600069.pl
1 use Modern::Perl;
2
3 return {
4     bug_number  => "34869",
5     description => "Move OPACResultsSidebar to additional contents",
6     up          => sub {
7         my ($args) = @_;
8         my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10         # Get any existing value from the OPACResultsSidebar system preference
11         my ($opacresultssidebar) = $dbh->selectrow_array(
12             q|
13             SELECT value FROM systempreferences WHERE variable='OPACResultsSidebar';
14         |
15         );
16         if ($opacresultssidebar) {
17
18             # Insert any values found from system preference into additional_contents
19             $dbh->do(
20                 "INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'OPACResultsSidebar', 'OPACResultsSidebar', NULL, CAST(NOW() AS date) )"
21             );
22
23             my ($insert_id) = $dbh->selectrow_array(
24                 "SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'OPACResultsSidebar' AND location = 'OPACResultsSidebar' LIMIT 1",
25                 {}
26             );
27
28             $dbh->do(
29                 "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'OPACResultsSidebar default', ?, 'default' )",
30                 undef, $insert_id, $opacresultssidebar
31             );
32
33             say $out "Added 'OpacMaintenanceNotice' additional content";
34         }
35
36         # Remove old system preference
37         $dbh->do("DELETE FROM systempreferences WHERE variable='OPACResultsSidebar'");
38         say $out "Removed system preference 'OPACResultsSidebar'";
39
40     },
41 };