From cc9c37b90e98497cce9274789172400b5d482cc3 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Thu, 4 Aug 2022 09:33:13 +0000
Subject: [PATCH] Bug 29144: Copy and remove branches.opac_info (dbrev)
Content-Type: text/plain; charset=utf-8

Test plan:
Run dbrev.
Check api URL: /api/v1/public/libraries (with/without suffix /[branch_code].

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 api/v1/swagger/definitions/library.yaml       |  5 -----
 api/v1/swagger/paths/libraries.yaml           |  5 -----
 .../data/mysql/atomicupdate/bug_29144.pl      | 19 +++++++++++++++++++
 installer/data/mysql/kohastructure.sql        |  1 -
 4 files changed, 19 insertions(+), 11 deletions(-)
 create mode 100755 installer/data/mysql/atomicupdate/bug_29144.pl

diff --git a/api/v1/swagger/definitions/library.yaml b/api/v1/swagger/definitions/library.yaml
index c3a4daaff0..de010c50d3 100644
--- a/api/v1/swagger/definitions/library.yaml
+++ b/api/v1/swagger/definitions/library.yaml
@@ -89,11 +89,6 @@ properties:
       - string
       - "null"
     description: notes related to your library or branch
-  opac_info:
-    type:
-      - string
-      - "null"
-    description: HTML that displays in OPAC
   geolocation:
     type:
       - string
diff --git a/api/v1/swagger/paths/libraries.yaml b/api/v1/swagger/paths/libraries.yaml
index b2bd863439..045f884a6d 100644
--- a/api/v1/swagger/paths/libraries.yaml
+++ b/api/v1/swagger/paths/libraries.yaml
@@ -87,11 +87,6 @@
         description: Case insensitive 'starts_with' search on notes
         required: false
         type: string
-      - name: opac_info
-        in: query
-        description: Case insensitive 'starts-with' search on OPAC info
-        required: false
-        type: string
       - $ref: "../swagger.yaml#/parameters/match"
       - $ref: "../swagger.yaml#/parameters/order_by"
       - $ref: "../swagger.yaml#/parameters/page"
diff --git a/installer/data/mysql/atomicupdate/bug_29144.pl b/installer/data/mysql/atomicupdate/bug_29144.pl
new file mode 100755
index 0000000000..8d9ff107ba
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_29144.pl
@@ -0,0 +1,19 @@
+use Modern::Perl;
+
+return {
+    bug_number => 29144,
+    description => "Copy and remove branches.opac_info",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        $dbh->do(q{
+INSERT IGNORE INTO additional_contents ( category,code,location,branchcode,title,content,lang,published_on )
+SELECT 'html_customizations', CONCAT('OpacLibraryInfo_', branches.branchcode), 'OpacLibraryInfo', branches.branchcode, branches.branchname, branches.opac_info, 'default', NOW()
+FROM branches
+WHERE branches.opac_info IS NOT NULL
+        });
+        $dbh->do(q{
+ALTER TABLE branches DROP COLUMN opac_info;
+        });
+    },
+};
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 3f524aec6a..257d5d4e4c 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1529,7 +1529,6 @@ CREATE TABLE `branches` (
   `issuing` tinyint(4) DEFAULT NULL COMMENT 'unused in Koha',
   `branchip` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'the IP address for your library or branch',
   `branchnotes` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'notes related to your library or branch',
-  `opac_info` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'HTML that displays in OPAC',
   `geolocation` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'geolocation of your library',
   `marcorgcode` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode',
   `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location',
-- 
2.20.1