From ddf6d918e7628d5d5f152113cd1a2a18a868023b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 11 Jan 2024 10:24:04 +0000 Subject: [PATCH] Bug 35473: Handle room reservations plugin conflict We now look for the existance of the room reservations 'bookings' table prior to attempting to install the core bookings table and migrate it in the same way the upstream plugin does before proceeding with installing the core bookings tables. Signed-off-by: Kyle M Hall --- installer/data/mysql/db_revs/230600061.pl | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/installer/data/mysql/db_revs/230600061.pl b/installer/data/mysql/db_revs/230600061.pl index 31c2cc43bda..b32763dbcec 100755 --- a/installer/data/mysql/db_revs/230600061.pl +++ b/installer/data/mysql/db_revs/230600061.pl @@ -6,6 +6,55 @@ return { up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; + # Handle cases of roombookings plugin existing + if ( TableExists('bookings') ) { + if ( column_exists( 'bookings', 'bookingid' ) ) { + my $old_rooms_table = 'booking_rooms'; + my $old_rooms_index = 'bookingrooms_idx'; + my $old_bookings_table = 'bookings'; + my $old_bookings_index = 'bookingbookings_idx'; + my $old_equipment_table = 'booking_equipment'; + my $old_equipment_index = 'bookingequipment_idx'; + my $old_roomequipment_table = 'booking_room_equipment'; + my $old_roomequipment_index = 'bookingroomequipment_idx'; + + my $prefix = 'bws_rr_'; + our $rooms_table = $prefix . $old_rooms_table; + our $rooms_index = $prefix . $old_rooms_index; + our $bookings_table = $prefix . $old_bookings_table; + our $bookings_index = $prefix . $old_bookings_index; + our $equipment_table = $prefix . $old_equipment_table; + our $equipment_index = $prefix . $old_equipment_index; + our $roomequipment_table = $prefix . $old_roomequipment_table; + our $roomequipment_index = $prefix . $old_roomequipment_index; + + $dbh->do( + qq{ + RENAME TABLE + $old_rooms_table TO $rooms_table, + $old_bookings_table TO $bookings_table, + $old_equipment_table TO $equipment_table, + $old_roomequipment_table TO $roomequipment_table, + } + ); + $dbh->do( +"ALTER TABLE $rooms_table RENAME INDEX $old_rooms_index TO $rooms_index" + ); + $dbh->do( +"ALTER TABLE $bookings_table RENAME INDEX $old_bookings_index TO $bookings_index" + ); + $dbh->do( +"ALTER TABLE $equipment_table RENAME INDEX $old_equipment_index TO $equipment_index" + ); + $dbh->do( +"ALTER TABLE $roomequipment_table RENAME INDEX $old_roomequipment_index TO $roomequipment_index" + ); + + say "Migrated room reservations plugin to it's own namespace"; + say "You MUST upgrade to the latest room reservation plugin to continue using it"; + } + } + if ( !TableExists('bookings') ) { $dbh->do( q{ -- 2.30.2