Bug 20912: (QA follow-up) Make DB Update idempotent

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2019-01-30 11:42:57 +00:00 committed by Nick Clemens
parent 6fe5466e5a
commit 04ac65ba19
2 changed files with 15 additions and 1 deletions

View File

@ -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";
}

View File

@ -1 +0,0 @@
ALTER TABLE itemtypes ADD COLUMN rental_charge_daily decimal(28,6) default NULL AFTER rentalcharge;