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 <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-05-05 16:04:42 +02:00 committed by Katrin Fischer
parent 4800537201
commit fcf679b920
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
8 changed files with 69 additions and 11 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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)'
}
);
},
};

View File

@ -3986,10 +3986,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`),
@ -5041,10 +5041,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`),
@ -5120,13 +5120,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;