Bug 24223: DBRev 21.06.00.045
[koha.git] / installer / data / mysql / db_revs / 210600045.pl
1 use Modern::Perl;
2
3 return {
4     bug_number => "24223",
5     description => "Move contents of OpacNav system preference into additional contents",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9
10         # Get any existing value from the OpacNav system preference
11         my ($opacnav) = $dbh->selectrow_array( q|
12             SELECT value FROM systempreferences WHERE variable='OpacNav';
13         |);
14         if( $opacnav ){
15             # If there is a value in the OpacNav preference, insert it into additional_contents
16             $dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacNav', 'OpacNav', NULL, ?, ?, 'default', CAST(NOW() AS date) )", undef, "OpacNav default", $opacnav );
17
18             # Remove the OpacNav system preference
19             $dbh->do("DELETE FROM systempreferences WHERE variable='OpacNav'");
20         } else {
21             say $out "No OpacNav preference found. Update has already been run.";
22         }
23
24     },
25 }