From ff11921a2c8ad11ddc67cb9e6206c7655ea19325 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Thu, 21 Dec 2023 09:05:54 +0000
Subject: [PATCH] Bug 35625: Add is_system to additional_fields table

---
 installer/data/mysql/atomicupdate/bug_35625.pl | 17 +++++++++++++++++
 installer/data/mysql/kohastructure.sql         |  1 +
 2 files changed, 18 insertions(+)
 create mode 100755 installer/data/mysql/atomicupdate/bug_35625.pl

diff --git a/installer/data/mysql/atomicupdate/bug_35625.pl b/installer/data/mysql/atomicupdate/bug_35625.pl
new file mode 100755
index 00000000000..f47131d9baf
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_35625.pl
@@ -0,0 +1,17 @@
+use Modern::Perl;
+
+return {
+    bug_number  => "35625",
+    description => "Add is_system field to additional_fields table",
+    up          => sub {
+        my ($args) = @_;
+        my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+        unless ( column_exists( 'additional_fields', 'is_system' ) ) {
+            $dbh->do(
+                "ALTER TABLE `additional_fields` ADD COLUMN `is_system` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is this field required for system operation' AFTER `tablename`"
+            );
+            say $out "Added column 'additional_fields.is_system'";
+        }
+    },
+};
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index f7078124876..3026da5892d 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -259,6 +259,7 @@ DROP TABLE IF EXISTS `additional_fields`;
 CREATE TABLE `additional_fields` (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier',
   `tablename` varchar(255) NOT NULL DEFAULT '' COMMENT 'tablename of the new field',
+  `is_system` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is this field required for system operation',
   `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the field',
   `authorised_value_category` varchar(32) DEFAULT NULL COMMENT 'is an authorised value category',
   `marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record',
-- 
2.43.0