Bug 24220: DBRev 21.12.00.012
[koha.git] / installer / data / mysql / db_revs / 211200012.pl
1 use Modern::Perl;
2
3 return {
4     bug_number => "24220",
5     description => "Move OpacMoreSearches to additional contents",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9         # Get any existing value from the OpacMoreSearches system preference
10         my ( $opacmoresearches ) = $dbh->selectrow_array(q{
11             SELECT value FROM systempreferences WHERE variable='OpacMoreSearches'
12         });
13         if( $opacmoresearches ){
14             # Insert any values found from system preference into additional_contents
15             $dbh->do(q{
16                 INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on )
17                 VALUES ('html_customizations', 'OpacMoreSearches', 'OpacMoreSearches', NULL, ?, ?, ?, CAST(NOW() AS date) )
18             }, undef, "OpacMoreSearches default", $opacmoresearches, 'default');
19             # Remove old system preference
20             $dbh->do(q{
21                 DELETE FROM systempreferences WHERE variable='OpacMoreSearches'
22             });
23         } else {
24             say $out "No OpacMoreSearches preference found. Value was empty or update has already been run.";
25         }
26     },
27 };