From d489b7d014cc822306e31710a88ac5cf778f5066 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 May 2025 16:04:42 +0200 Subject: [PATCH] Bug 39835: Modify boolean column from int(1) to tinyint(1) This is part of our guideline and we should enforce it. This patch also add "is_boolean => 0" for int(1) that are not boolean Signed-off-by: Tomas Cohen Arazi --- Koha/Schema/Result/Aqbudget.pm | 4 +++ Koha/Schema/Result/ColumnsSetting.pm | 5 ++- Koha/Schema/Result/CreatorLayout.pm | 7 ++-- Koha/Schema/Result/Overduerule.pm | 6 ++++ .../Result/OverduerulesTransportType.pm | 4 ++- Koha/Schema/Result/TagsApproval.pm | 4 +++ .../data/mysql/atomicupdate/bug_39835.pl | 36 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 14 ++++---- 8 files changed, 69 insertions(+), 11 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_39835.pl diff --git a/Koha/Schema/Result/Aqbudget.pm b/Koha/Schema/Result/Aqbudget.pm index 01a0ff6d397..2bc5993428d 100644 --- a/Koha/Schema/Result/Aqbudget.pm +++ b/Koha/Schema/Result/Aqbudget.pm @@ -369,6 +369,10 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->add_columns( + '+budget_permission' => { is_boolean => 0 }, +); + =head2 koha_object_class Missing POD for koha_object_class. diff --git a/Koha/Schema/Result/ColumnsSetting.pm b/Koha/Schema/Result/ColumnsSetting.pm index 0bd430766dc..a2f50322dca 100644 --- a/Koha/Schema/Result/ColumnsSetting.pm +++ b/Koha/Schema/Result/ColumnsSetting.pm @@ -98,6 +98,9 @@ __PACKAGE__->set_primary_key("module", "page", "tablename", "columnname"); # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-12-12 16:06:36 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IhREpW2PRxxFF9EYOGt2Qg +__PACKAGE__->add_columns( + '+cannot_be_toggled' => { is_boolean => 1 }, + '+is_hidden' => { 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/CreatorLayout.pm b/Koha/Schema/Result/CreatorLayout.pm index 1dd3263b8fa..b9c1f688b1f 100644 --- a/Koha/Schema/Result/CreatorLayout.pm +++ b/Koha/Schema/Result/CreatorLayout.pm @@ -219,6 +219,9 @@ __PACKAGE__->set_primary_key("layout_id"); # Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-05-24 13:05:15 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W/ICw+9yY7wxZ0IgqqXcFg - -# You can replace this text with custom content, and it will be preserved on regeneration +__PACKAGE__->add_columns( + '+guidebox' => { is_boolean => 0 }, + '+oblique_title' => { is_boolean => 0 }, + '+callnum_split' => { is_boolean => 0 }, +); 1; diff --git a/Koha/Schema/Result/Overduerule.pm b/Koha/Schema/Result/Overduerule.pm index fc7dfe166fb..9a213e92fa0 100644 --- a/Koha/Schema/Result/Overduerule.pm +++ b/Koha/Schema/Result/Overduerule.pm @@ -198,6 +198,12 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pORigxtC5qztZWHI29mZ/g +__PACKAGE__->add_columns( + '+debarred1' => { is_boolean => 1 }, + '+debarred2' => { is_boolean => 1 }, + '+debarred3' => { is_boolean => 1 }, +); + =head2 koha_object_class Missing POD for koha_object_class. diff --git a/Koha/Schema/Result/OverduerulesTransportType.pm b/Koha/Schema/Result/OverduerulesTransportType.pm index e069a599e2c..f521844c35a 100644 --- a/Koha/Schema/Result/OverduerulesTransportType.pm +++ b/Koha/Schema/Result/OverduerulesTransportType.pm @@ -116,6 +116,8 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-03-31 15:44:38 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GV2VZ1kIA9Fl8pQd0qkrjg +__PACKAGE__->add_columns( + '+letternumber' => { is_boolean => 0 }, +); -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Koha/Schema/Result/TagsApproval.pm b/Koha/Schema/Result/TagsApproval.pm index 6edea9d3597..74b75af159f 100644 --- a/Koha/Schema/Result/TagsApproval.pm +++ b/Koha/Schema/Result/TagsApproval.pm @@ -135,6 +135,10 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PR7rfXKXExWpmkdxcXRrbQ +__PACKAGE__->add_columns( + '+approved' => { is_boolean => 0 }, +); + =head2 koha_object_class Missing POD for koha_object_class. diff --git a/installer/data/mysql/atomicupdate/bug_39835.pl b/installer/data/mysql/atomicupdate/bug_39835.pl new file mode 100755 index 00000000000..72136c6951b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39835.pl @@ -0,0 +1,36 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "39835", + description => "Switch datatype to TINYINT(1) when boolean", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + ALTER TABLE `issues` + MODIFY COLUMN `onsite_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', + MODIFY COLUMN `noteseen` tinyint(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null' + } + ); + + $dbh->do( + q{ + ALTER TABLE `old_issues` + MODIFY COLUMN `onsite_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', + MODIFY COLUMN `noteseen` tinyint(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null' + } + ); + + $dbh->do( + q{ + ALTER TABLE `overduerules` + MODIFY COLUMN `debarred1` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the first notice is sent (1 for yes, 0 for no)', + MODIFY COLUMN `debarred2` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the second notice is sent (1 for yes, 0 for no)', + MODIFY COLUMN `debarred3` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the third notice is sent (1 for yes, 0 for no)' + } + ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index f4d74a1d5b4..430d1e62dac 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3985,10 +3985,10 @@ CREATE TABLE `issues` ( `auto_renew_error` varchar(32) DEFAULT NULL COMMENT 'automatic renewal error', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched', `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued', - `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', + `onsite_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', `note` longtext DEFAULT NULL COMMENT 'issue note text', `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)', - `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null', + `noteseen` tinyint(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null', PRIMARY KEY (`issue_id`), UNIQUE KEY `itemnumber` (`itemnumber`), KEY `issuesborridx` (`borrowernumber`), @@ -5040,10 +5040,10 @@ CREATE TABLE `old_issues` ( `auto_renew_error` varchar(32) DEFAULT NULL COMMENT 'automatic renewal error', `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the date and time this record was last touched', `issuedate` datetime DEFAULT NULL COMMENT 'date the item was checked out or issued', - `onsite_checkout` int(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', + `onsite_checkout` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'in house use flag', `note` longtext DEFAULT NULL COMMENT 'issue note text', `notedate` datetime DEFAULT NULL COMMENT 'datetime of issue note (yyyy-mm-dd hh:mm::ss)', - `noteseen` int(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null', + `noteseen` tinyint(1) DEFAULT NULL COMMENT 'describes whether checkout note has been seen 1, not been seen 0 or doesn''t exist null', PRIMARY KEY (`issue_id`), KEY `old_issuesborridx` (`borrowernumber`), KEY `old_issuesitemidx` (`itemnumber`), @@ -5119,13 +5119,13 @@ CREATE TABLE `overduerules` ( `categorycode` varchar(10) NOT NULL DEFAULT '' COMMENT 'foreign key from the categories table to define which patron category this rule is for', `delay1` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the first notice is sent', `letter1` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the first notice', - `debarred1` varchar(1) DEFAULT '0' COMMENT 'is the patron restricted when the first notice is sent (1 for yes, 0 for no)', + `debarred1` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the first notice is sent (1 for yes, 0 for no)', `delay2` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the second notice is sent', - `debarred2` varchar(1) DEFAULT '0' COMMENT 'is the patron restricted when the second notice is sent (1 for yes, 0 for no)', + `debarred2` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the second notice is sent (1 for yes, 0 for no)', `letter2` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the second notice', `delay3` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the third notice is sent', `letter3` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the third notice', - `debarred3` int(1) DEFAULT 0 COMMENT 'is the patron restricted when the third notice is sent (1 for yes, 0 for no)', + `debarred3` tinyint(1) DEFAULT 0 COMMENT 'is the patron restricted when the third notice is sent (1 for yes, 0 for no)', PRIMARY KEY (`overduerules_id`), UNIQUE KEY `overduerules_branch_cat` (`branchcode`,`categorycode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.49.0