Bug 22844: Add the new DB column borrower_attribute_types.mandatory
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 17 May 2019 14:06:04 +0000 (09:06 -0500)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Jul 2020 14:08:22 +0000 (16:08 +0200)
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

https://bugs.koha-community.org/show_bug.cgi?id=23391

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

installer/data/mysql/atomicupdate/bug_22844.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_22844.perl b/installer/data/mysql/atomicupdate/bug_22844.perl
new file mode 100644 (file)
index 0000000..4b1d12f
--- /dev/null
@@ -0,0 +1,14 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+
+    if( !column_exists( 'borrower_attribute_types', 'mandatory' ) ) {
+        $dbh->do(q|
+            ALTER TABLE borrower_attribute_types
+            ADD COLUMN mandatory TINYINT(1) NOT NULL DEFAULT 0
+            AFTER keep_for_pseudonymization
+        |);
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug XXXXX - Add borrower_attribute_types.mandatory)\n";
+}
index ba71898..d64b31d 100644 (file)
@@ -229,6 +229,7 @@ CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron field
   `category_code` VARCHAR(10) NULL DEFAULT NULL,-- defines a category for an attribute_type
   `class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
   `keep_for_pseudonymization` tinyint(1) NOT NULL default 0, -- defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)
+  `mandatory` tinyint(1) NOT NULL DEFAULT 0, -- defines if the attribute is mandatory or not
   PRIMARY KEY  (`code`),
   KEY `auth_val_cat_idx` (`authorised_value_category`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;