From 07d4ae2733146c8e7bb4a80e3f09335bc223f8af Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Apr 2020 16:15:33 +0200 Subject: [PATCH] Bug 21294: Replace BOOLEAN with TINYINT(1) in our DB structure To match the coding guideline SQL12. We do this for consistency. Note that we do not need an update DB as BOOLEAN is an alias for TINYINT(1). The is_boolean flags have been added to the schema. Test plan: 1. `dbic` should run correctly 2. kohastructure.sql should be syntaxicaly correct 3. `git grep -i boolean installer/data/mysql/kohastructure.sql` should not return relevant occurrences. --- Koha/Schema/Result/Aqcontact.pm | 8 ++++++ Koha/Schema/Result/EdifactMessage.pm | 3 +++ Koha/Schema/Result/OldReserve.pm | 6 +++++ Koha/Schema/Result/SavedSql.pm | 4 +++ Koha/Schema/Result/SearchMarcToField.pm | 6 ++++- Koha/Schema/Result/Subscription.pm | 3 ++- installer/data/mysql/kohastructure.sql | 34 ++++++++++++------------- 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/Koha/Schema/Result/Aqcontact.pm b/Koha/Schema/Result/Aqcontact.pm index b9dc1cb65a..0de8efc761 100644 --- a/Koha/Schema/Result/Aqcontact.pm +++ b/Koha/Schema/Result/Aqcontact.pm @@ -172,6 +172,14 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:R2x8Z9Db2oDULEODgLuw8Q +__PACKAGE__->add_columns( + '+orderacquisition' => { is_boolean => 1 }, + '+claimacquisition' => { is_boolean => 1 }, + '+claimissues' => { is_boolean => 1 }, + '+acqprimary' => { is_boolean => 1 }, + '+serialsprimary' => { is_boolean => 1 }, +); + sub koha_object_class { 'Koha::Acquisition::Bookseller::Contact'; } diff --git a/Koha/Schema/Result/EdifactMessage.pm b/Koha/Schema/Result/EdifactMessage.pm index 7e0c4feff2..db24e7468c 100644 --- a/Koha/Schema/Result/EdifactMessage.pm +++ b/Koha/Schema/Result/EdifactMessage.pm @@ -198,5 +198,8 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JHUEsQ+kXjGTRxxc2FFSjQ +__PACKAGE__->add_columns( + '+deleted' => { is_boolean => 1 }, +); 1; diff --git a/Koha/Schema/Result/OldReserve.pm b/Koha/Schema/Result/OldReserve.pm index 85e604d288..3df98cc4e5 100644 --- a/Koha/Schema/Result/OldReserve.pm +++ b/Koha/Schema/Result/OldReserve.pm @@ -301,6 +301,12 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-18 12:43:15 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4vMUC/1kSr3vgQ7n0Pmuug +__PACKAGE__->add_columns( + '+item_level_hold' => { is_boolean => 1 }, + '+lowestPriority' => { is_boolean => 1 }, + '+suspend' => { is_boolean => 1 } +); + sub koha_object_class { 'Koha::Old::Hold'; } diff --git a/Koha/Schema/Result/SavedSql.pm b/Koha/Schema/Result/SavedSql.pm index f8567b3723..833c4fe21f 100644 --- a/Koha/Schema/Result/SavedSql.pm +++ b/Koha/Schema/Result/SavedSql.pm @@ -173,6 +173,10 @@ __PACKAGE__->set_primary_key("id"); # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-23 12:56:39 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f7wxGGnBk3z6mw2CkaeD9A +__PACKAGE__->add_columns( + '+public' => { is_boolean => 1 } +); + sub koha_object_class { 'Koha::Report'; } diff --git a/Koha/Schema/Result/SearchMarcToField.pm b/Koha/Schema/Result/SearchMarcToField.pm index 01080160b9..527110140d 100644 --- a/Koha/Schema/Result/SearchMarcToField.pm +++ b/Koha/Schema/Result/SearchMarcToField.pm @@ -131,6 +131,10 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-02 12:47:22 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9mqZ/zrii+Fv+k+eQNHYUw +__PACKAGE__->add_columns( + '+facet' => { is_boolean => 1 }, + '+suggestible' => { is_boolean => 1 }, + '+sort' => { is_boolean => 1 }, +); -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Koha/Schema/Result/Subscription.pm b/Koha/Schema/Result/Subscription.pm index 735cd05655..2d187c38ef 100644 --- a/Koha/Schema/Result/Subscription.pm +++ b/Koha/Schema/Result/Subscription.pm @@ -472,7 +472,8 @@ __PACKAGE__->has_many( ); __PACKAGE__->add_columns( - '+closed' => { is_boolean => 1 }, + '+closed' => { is_boolean => 1 }, + '+skip_serialseq' => { is_boolean => 1 }, ); # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 740b5958c8..b81a9d71c3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1326,7 +1326,7 @@ CREATE TABLE saved_sql ( -- saved sql reports `type` varchar(255) default NULL, -- always 1 for tabular `notes` MEDIUMTEXT, -- the notes or description given to this report `cache_expiry` int NOT NULL default 300, - `public` boolean NOT NULL default FALSE, + `public` tinyint(1) NOT NULL default FALSE, report_area varchar(6) default NULL, report_group varchar(80) default NULL, report_subgroup varchar(80) default NULL, @@ -1411,9 +1411,9 @@ CREATE TABLE `search_marc_to_field` ( search tinyint(1) NOT NULL DEFAULT 1, search_marc_map_id int(11) NOT NULL, search_field_id int(11) NOT NULL, - facet boolean DEFAULT FALSE COMMENT 'true if a facet field should be generated for this', - suggestible boolean DEFAULT FALSE COMMENT 'true if this field can be used to generate suggestions for browse', - sort boolean DEFAULT NULL COMMENT 'true/false creates special sort handling, null doesn''t', + facet tinyint(1) DEFAULT FALSE COMMENT 'true if a facet field should be generated for this', + suggestible tinyint(1) DEFAULT FALSE COMMENT 'true if this field can be used to generate suggestions for browse', + sort tinyint(1) DEFAULT NULL COMMENT 'true/false creates special sort handling, null doesn''t', PRIMARY KEY(search_marc_map_id, search_field_id), FOREIGN KEY(search_marc_map_id) REFERENCES search_marc_map(id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(search_field_id) REFERENCES search_field(id) ON DELETE CASCADE ON UPDATE CASCADE @@ -1635,7 +1635,7 @@ CREATE TABLE `issues` ( -- information related to check outs or issues `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues `lastreneweddate` datetime default NULL, -- date the item was last renewed `renewals` tinyint(4) NOT NULL default 0, -- lists the number of times the item was renewed - `auto_renew` BOOLEAN default FALSE, -- automatic renewal + `auto_renew` tinyint(1) default FALSE, -- automatic renewal `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched `issuedate` datetime default NULL, -- date the item was checked out or issued @@ -1667,7 +1667,7 @@ CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r `returndate` datetime default NULL, -- date the item was returned `lastreneweddate` datetime default NULL, -- date the item was last renewed `renewals` tinyint(4) NOT NULL default 0, -- lists the number of times the item was renewed - `auto_renew` BOOLEAN default FALSE, -- automatic renewal + `auto_renew` tinyint(1) default FALSE, -- automatic renewal `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched `issuedate` datetime default NULL, -- date the item was checked out or issued @@ -1783,10 +1783,10 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date) `lowestPriority` tinyint(1) NOT NULL DEFAULT 0, - `suspend` BOOLEAN NOT NULL DEFAULT 0, + `suspend` tinyint(1) NOT NULL DEFAULT 0, `suspend_until` DATETIME NULL DEFAULT NULL, `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting - `item_level_hold` BOOLEAN NOT NULL DEFAULT 0, -- Is the hpld placed at item level + `item_level_hold` tinyint(1) NOT NULL DEFAULT 0, -- Is the hpld placed at item level PRIMARY KEY (`reserve_id`), KEY priorityfoundidx (priority,found), KEY `borrowernumber` (`borrowernumber`), @@ -1823,10 +1823,10 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b `waitingdate` date default NULL, -- the date the item was marked as waiting for the patron at the library `expirationdate` DATE DEFAULT NULL, -- the date the hold expires (usually the date entered by the patron to say they don't need the hold after a certain date) `lowestPriority` tinyint(1) NOT NULL DEFAULT 0, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no) - `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no) + `suspend` tinyint(1) NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no) `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely) `itemtype` VARCHAR(10) NULL DEFAULT NULL, -- If record level hold, the optional itemtype of the item the patron is requesting - `item_level_hold` BOOLEAN NOT NULL DEFAULT 0, -- Is the hpld placed at item level + `item_level_hold` tinyint(1) NOT NULL DEFAULT 0, -- Is the hpld placed at item level PRIMARY KEY (`reserve_id`), KEY `old_reserves_borrowernumber` (`borrowernumber`), KEY `old_reserves_biblionumber` (`biblionumber`), @@ -1979,7 +1979,7 @@ CREATE TABLE `subscription` ( -- information related to the subscription `firstacquidate` date default NULL, -- first issue received date `manualhistory` tinyint(1) NOT NULL default 0, -- yes or no to managing the history manually `irregularity` MEDIUMTEXT, -- any irregularities in the subscription - skip_serialseq BOOLEAN NOT NULL DEFAULT 0, + skip_serialseq tinyint(1) NOT NULL DEFAULT 0, `letter` varchar(20) default NULL, `numberpattern` integer default null, -- the numbering pattern used links to subscription_numberpatterns.id locale VARCHAR(80) DEFAULT NULL, -- for foreign language subscriptions to display months, seasons, etc correctly @@ -2922,11 +2922,11 @@ CREATE TABLE aqcontacts ( fax varchar(100) default NULL, -- contact's fax number email varchar(100) default NULL, -- contact's email address notes LONGTEXT, -- notes related to the contact - orderacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisition orders - claimacquisition BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims - claimissues BOOLEAN NOT NULL DEFAULT 0, -- should this contact receive serial claims - acqprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages - serialsprimary BOOLEAN NOT NULL DEFAULT 0, -- is this the primary contact for serials messages + orderacquisition tinyint(1) NOT NULL DEFAULT 0, -- should this contact receive acquisition orders + claimacquisition tinyint(1) NOT NULL DEFAULT 0, -- should this contact receive acquisitions claims + claimissues tinyint(1) NOT NULL DEFAULT 0, -- should this contact receive serial claims + acqprimary tinyint(1) NOT NULL DEFAULT 0, -- is this the primary contact for acquisitions messages + serialsprimary tinyint(1) NOT NULL DEFAULT 0, -- is this the primary contact for serials messages booksellerid int(11) not NULL, PRIMARY KEY (id), CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid) @@ -3102,7 +3102,7 @@ CREATE TABLE IF NOT EXISTS edifact_messages ( basketno INT(11) REFERENCES aqbasket( basketno), raw_msg LONGTEXT, filename MEDIUMTEXT, - deleted BOOLEAN NOT NULL DEFAULT 0, + deleted tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY vendorid ( vendor_id), KEY ediacct (edi_acct), -- 2.20.1