From d38be59a48bb4f3a2dce64947731f3288ba58a50 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 7 Sep 2021 08:06:59 -0300 Subject: [PATCH] Bug 28959: Move category => public MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- .../data/mysql/atomicupdate/bug_28959.pl | 30 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_28959.pl diff --git a/installer/data/mysql/atomicupdate/bug_28959.pl b/installer/data/mysql/atomicupdate/bug_28959.pl new file mode 100755 index 0000000000..f3061d99bf --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28959.pl @@ -0,0 +1,30 @@ +use Modern::Perl; + +return { + bug_number => "28959", + description => "virtualshelves.category is really a boolean", + up => sub { + my ($args) = @_; + my ($dbh) = @$args{qw(dbh)}; + + unless( column_exists( 'virtualshelves', 'public' ) ) { + # Add column + $dbh->do(q{ + ALTER TABLE virtualshelves + ADD COLUMN `public` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'If the list is public' + AFTER `owner`; + }); + # Set public lists + $dbh->do(q{ + UPDATE virtualshelves + SET public = 1 + WHERE category = 2; + }); + # Drop old column + $dbh->do(q{ + ALTER TABLE virtualshelves + DROP COLUMN `category`; + }); + } + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e61c06592f..f6bd1ed2e7 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5292,7 +5292,7 @@ CREATE TABLE `virtualshelves` ( `shelfnumber` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha', `shelfname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'name of the list', `owner` int(11) DEFAULT NULL COMMENT 'foreign key linking to the borrowers table (using borrowernumber) for the creator of this list (changed from varchar(80) to int)', - `category` varchar(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'type of list (private [1], public [2])', + `public` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'If the list is public', `sortfield` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT 'title' COMMENT 'the field this list is sorted on', `lastmodified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time the list was last modified', `created_on` datetime NOT NULL COMMENT 'creation time', -- 2.39.5