From 52c11b6633bfc13847f5acdbdb471178c54e0830 Mon Sep 17 00:00:00 2001
From: Lucas Gass <lucas@bywatersolutions.com>
Date: Fri, 7 Jun 2024 16:14:33 +0000
Subject: [PATCH] Bug 37054: DBUpdate

Signed-off-by: David Nind <david@davidnind.com>
---
 .../atomicupdate/bug_37054_add_branchcolor.pl | 23 +++++++++++++++++++
 installer/data/mysql/kohastructure.sql        |  1 +
 2 files changed, 24 insertions(+)
 create mode 100755 installer/data/mysql/atomicupdate/bug_37054_add_branchcolor.pl

diff --git a/installer/data/mysql/atomicupdate/bug_37054_add_branchcolor.pl b/installer/data/mysql/atomicupdate/bug_37054_add_branchcolor.pl
new file mode 100755
index 0000000000..8bb54539bc
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_37054_add_branchcolor.pl
@@ -0,0 +1,23 @@
+use Modern::Perl;
+use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
+
+return {
+    bug_number  => "37054",
+    description => "Add branches.branchcolor",
+    up          => sub {
+        my ($args) = @_;
+        my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+        if ( !column_exists( 'branches', 'branchcolor' ) ) {
+            $dbh->do(
+                q{
+                ALTER TABLE branches
+                ADD COLUMN `branchcolor` varchar(16) DEFAULT 0 COMMENT 'defines the branch color'
+                AFTER `opacusercss`
+            }
+            );
+        }
+        say $out "Added column 'branch.branchcolor'";
+
+    },
+};
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 91c1bec42f..1262047726 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1665,6 +1665,7 @@ CREATE TABLE `branches` (
   `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac',
   `opacuserjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC',
   `opacusercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC',
+  `branchcolor` varchar(16) DEFAULT NULL COMMENT 'branch specific color',
   PRIMARY KEY (`branchcode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
-- 
2.39.2