Browse Source

Bug 18235: (QA follow-up) Make db update idempotent

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Josef Moravec 3 years ago
committed by Nick Clemens
parent
commit
b311938370
  1. 20
      installer/data/mysql/atomicupdate/bug_18235-add-search_field-facet_order.perl
  2. 10
      installer/data/mysql/atomicupdate/bug_18235-add-search_field-facet_order.sql

20
installer/data/mysql/atomicupdate/bug_18235-add-search_field-facet_order.perl

@ -0,0 +1,20 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'search_field', 'facet_order' ) ) {
$dbh->do("ALTER TABLE search_field ADD COLUMN facet_order TINYINT(4) DEFAULT NULL AFTER weight");
}
$dbh->do("UPDATE search_field SET facet_order=1 WHERE name='author'");
$dbh->do("UPDATE search_field SET facet_order=2 WHERE name='itype'");
$dbh->do("UPDATE search_field SET facet_order=3 WHERE name='location'");
$dbh->do("UPDATE search_field SET facet_order=4 WHERE name='su-geo'");
$dbh->do("UPDATE search_field SET facet_order=5 WHERE name='se'");
$dbh->do("UPDATE search_field SET facet_order=6 WHERE name='subject'");
$dbh->do("UPDATE search_field SET facet_order=7 WHERE name='ccode'");
$dbh->do("UPDATE search_field SET facet_order=8 WHERE name='holdingbranch'");
$dbh->do("UPDATE search_field SET facet_order=9 WHERE name='homebranch'");
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 18235 - Elastic search - make facets configurable)\n";
}

10
installer/data/mysql/atomicupdate/bug_18235-add-search_field-facet_order.sql

@ -1,10 +0,0 @@
ALTER TABLE search_field ADD COLUMN facet_order TINYINT(4) DEFAULT NULL AFTER weight;
UPDATE search_field SET facet_order=1 WHERE name='author';
UPDATE search_field SET facet_order=2 WHERE name='itype';
UPDATE search_field SET facet_order=3 WHERE name='location';
UPDATE search_field SET facet_order=4 WHERE name='su-geo';
UPDATE search_field SET facet_order=5 WHERE name='se';
UPDATE search_field SET facet_order=6 WHERE name='subject';
UPDATE search_field SET facet_order=7 WHERE name='ccode';
UPDATE search_field SET facet_order=8 WHERE name='holdingbranch';
UPDATE search_field SET facet_order=9 WHERE name='homebranch';
Loading…
Cancel
Save