From 51dcd7b28300696700de997b7a81e09c85680e29 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 30 Jan 2019 11:42:57 +0000 Subject: [PATCH] Bug 20912: (QA follow-up) Make DB Update idempotent Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/bug_20912.perl | 15 +++++++++++++++ installer/data/mysql/atomicupdate/bug_20912.sql | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_20912.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_20912.sql diff --git a/installer/data/mysql/atomicupdate/bug_20912.perl b/installer/data/mysql/atomicupdate/bug_20912.perl new file mode 100644 index 0000000000..6e5f9ed212 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_20912.perl @@ -0,0 +1,15 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if ( CheckVersion($DBversion) ) { + + if ( !column_exists( 'itemtypes', 'rentalcharge_daily' ) ) { + $dbh->do("ALTER TABLE `itemtypes` ADD COLUMN `rentalcharge_daily` decimal(28,6) default NULL AFTER `rentalcharge`"); + } + + if ( column_exists( 'itemtypes', 'rental_charge_daily' ) ) { + $dbh->do("UPDATE `itemtypes` SET `rentalcharge_daily` = `rental_charge_daily`"); + $dbh->do("ALTER TABLE `itemtypes` DROP COLUMN `rental_charge_daily`"); + } + + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 20912 - Support granular rental charges)\n"; +} diff --git a/installer/data/mysql/atomicupdate/bug_20912.sql b/installer/data/mysql/atomicupdate/bug_20912.sql deleted file mode 100644 index 459c9b30e3..0000000000 --- a/installer/data/mysql/atomicupdate/bug_20912.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE itemtypes ADD COLUMN rental_charge_daily decimal(28,6) default NULL AFTER rentalcharge; -- 2.20.1