Lines 6-11
return {
Link Here
|
6 |
up => sub { |
6 |
up => sub { |
7 |
my ($args) = @_; |
7 |
my ($args) = @_; |
8 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
8 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
|
|
9 |
# Handle cases of roombookings plugin existing |
10 |
if ( TableExists('bookings') ) { |
11 |
if ( column_exists( 'bookings', 'bookingid' ) ) { |
12 |
my $old_rooms_table = 'booking_rooms'; |
13 |
my $old_rooms_index = 'bookingrooms_idx'; |
14 |
my $old_bookings_table = 'bookings'; |
15 |
my $old_bookings_index = 'bookingbookings_idx'; |
16 |
my $old_equipment_table = 'booking_equipment'; |
17 |
my $old_equipment_index = 'bookingequipment_idx'; |
18 |
my $old_roomequipment_table = 'booking_room_equipment'; |
19 |
my $old_roomequipment_index = 'bookingroomequipment_idx'; |
20 |
|
21 |
my $prefix = 'bws_rr_'; |
22 |
our $rooms_table = $prefix . $old_rooms_table; |
23 |
our $rooms_index = $prefix . $old_rooms_index; |
24 |
our $bookings_table = $prefix . $old_bookings_table; |
25 |
our $bookings_index = $prefix . $old_bookings_index; |
26 |
our $equipment_table = $prefix . $old_equipment_table; |
27 |
our $equipment_index = $prefix . $old_equipment_index; |
28 |
our $roomequipment_table = $prefix . $old_roomequipment_table; |
29 |
our $roomequipment_index = $prefix . $old_roomequipment_index; |
30 |
|
31 |
$dbh->do( |
32 |
qq{ |
33 |
RENAME TABLE |
34 |
$old_rooms_table TO $rooms_table, |
35 |
$old_bookings_table TO $bookings_table, |
36 |
$old_equipment_table TO $equipment_table, |
37 |
$old_roomequipment_table TO $roomequipment_table, |
38 |
} |
39 |
); |
40 |
$dbh->do( |
41 |
"ALTER TABLE $rooms_table RENAME INDEX $old_rooms_index TO $rooms_index" |
42 |
); |
43 |
$dbh->do( |
44 |
"ALTER TABLE $bookings_table RENAME INDEX $old_bookings_index TO $bookings_index" |
45 |
); |
46 |
$dbh->do( |
47 |
"ALTER TABLE $equipment_table RENAME INDEX $old_equipment_index TO $equipment_index" |
48 |
); |
49 |
$dbh->do( |
50 |
"ALTER TABLE $roomequipment_table RENAME INDEX $old_roomequipment_index TO $roomequipment_index" |
51 |
); |
52 |
|
53 |
say "Migrated room reservations plugin to it's own namespace"; |
54 |
say "You MUST upgrade to the latest room reservation plugin to continue using it"; |
55 |
} |
56 |
} |
57 |
|
9 |
if ( !TableExists('bookings') ) { |
58 |
if ( !TableExists('bookings') ) { |
10 |
$dbh->do( |
59 |
$dbh->do( |
11 |
q{ |
60 |
q{ |
12 |
- |
|
|