Bug 34889: DBRev 23.06.00.070
[koha.git] / installer / data / mysql / db_revs / 230600070.pl
1 use Modern::Perl;
2
3 return {
4     bug_number  => "34889",
5     description => "Move PatronSelfRegistrationAdditionalInstructions 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 PatronSelfRegistrationAdditionalInstructions system preference
11         my ($patronselfregistrationadditionalinstructions) = $dbh->selectrow_array(
12             q|
13             SELECT value FROM systempreferences WHERE variable='PatronSelfRegistrationAdditionalInstructions';
14         |
15         );
16         if ($patronselfregistrationadditionalinstructions) {
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', 'PatronSelfRegistrationAdditionalInstructions', 'PatronSelfRegistrationAdditionalInstructions', 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 = 'PatronSelfRegistrationAdditionalInstructions' AND location = 'PatronSelfRegistrationAdditionalInstructions' LIMIT 1",
25                 {}
26             );
27
28             $dbh->do(
29                 "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'PatronSelfRegistrationAdditionalInstructions default', ?, 'default' )",
30                 undef, $insert_id, $patronselfregistrationadditionalinstructions
31             );
32
33             say $out "Added 'PatronSelfRegistrationAdditionalInstructions' additional content";
34         }
35
36         # Remove old system preference
37         $dbh->do("DELETE FROM systempreferences WHERE variable='PatronSelfRegistrationAdditionalInstructions'");
38         say $out "Removed system preference 'PatronSelfRegistrationAdditionalInstructions'";
39
40     },
41 };