From 520d1acac832fe299408eb393daaa5e434e88927 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Jul 2017 13:58:05 -0300 Subject: [PATCH] Bug 18228: DBRev 17.05.00.002 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug18228.perl | 30 ----------------- installer/data/mysql/updatedatabase.pl | 33 +++++++++++++++++++ 3 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug18228.perl diff --git a/Koha.pm b/Koha.pm index 12097100dd..620386a638 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "17.06.00.001"; +$VERSION = "17.06.00.002"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug18228.perl b/installer/data/mysql/atomicupdate/bug18228.perl deleted file mode 100644 index 3f94609009..0000000000 --- a/installer/data/mysql/atomicupdate/bug18228.perl +++ /dev/null @@ -1,30 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - # Add the new columns - $dbh->do( -q|ALTER TABLE virtualshelves -ADD COLUMN allow_change_from_owner tinyint(1) default 1, -ADD COLUMN allow_change_from_others tinyint(1) default 0| - ); - - # Conversion: - # Since we had no readonly lists, change_from_owner is set to true. - # When adding or delete_other was granted, change_from_others is true. - # Note: In my opinion the best choice; there is no exact match. - $dbh->do( -q|UPDATE virtualshelves -SET allow_change_from_owner = 1, -allow_change_from_others = CASE WHEN allow_add=1 OR allow_delete_other=1 THEN 1 ELSE 0 END| - ); - - # Remove the old columns - $dbh->do( -q|ALTER TABLE virtualshelves -DROP COLUMN allow_add, -DROP COLUMN allow_delete_own, -DROP COLUMN allow_delete_other| - ); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 18228 - Alter table virtualshelves)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index fea0a0aafe..b3d30d8b3a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -14541,6 +14541,39 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 8612 - Add new column export_format.used_for)\n"; } +$DBversion = '17.06.00.002'; +if ( CheckVersion($DBversion) ) { + + unless ( column_exists('virtualshelves', 'allow_change_from_owner' ) ) { + $dbh->do(q| + ALTER TABLE virtualshelves + ADD COLUMN allow_change_from_owner tinyint(1) default 1, + ADD COLUMN allow_change_from_others tinyint(1) default 0 + |); + + # Conversion: + # Since we had no readonly lists, change_from_owner is set to true. + # When adding or delete_other was granted, change_from_others is true. + # Note: In my opinion the best choice; there is no exact match. + $dbh->do(q| + UPDATE virtualshelves + SET allow_change_from_owner = 1, + allow_change_from_others = CASE WHEN allow_add=1 OR allow_delete_other=1 THEN 1 ELSE 0 END + |); + + # Remove the old columns + $dbh->do(q| + ALTER TABLE virtualshelves + DROP COLUMN allow_add, + DROP COLUMN allow_delete_own, + DROP COLUMN allow_delete_other + |); + } + + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 18228 - Alter table virtualshelves to simplify permissions)\n"; +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5