Bug 8367: Make database update idempotent (across different MariaDB versions)

The previous query seemed to work on MariaDB 10.1.48 (used by koha-testing-docker),
but it didn't work on MariaDB 10.3.29 (default in Debian 10 as of this writing),
but this patched query works on both indempotently.

Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kelly <kelly@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Kelly <kelly@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
David Cook 2021-09-21 05:21:42 +00:00 committed by Tomas Cohen Arazi
parent ea68ea1e4c
commit 015fb672c5
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -2,8 +2,8 @@ $DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {
$dbh->do(q{
INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
SELECT NULL, NULL, NULL, 'holds_pickup_period', ''
WHERE NOT EXISTS ( SELECT rule_name FROM circulation_rules where rule_name = 'holds_pickup_period' )
SELECT u.* FROM (SELECT NULL as branchcode, NULL as categorycode, NULL as itemtype, 'holds_pickup_period' as rule_name, '' as rule_value) u
WHERE NOT EXISTS ( SELECT rule_name FROM circulation_rules where rule_name = 'holds_pickup_period' );
});
NewVersion( $DBversion, 8367, "Add holds_pickup_period circulation rule" );