Koha/admin
Joonas Kylmälä 9c0dc6efff
Bug 17885: Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws DBD::mysql Duplicate entry exceptions
When executing
Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings()
against populated search engine mappings tables, one gets this
exception:

DBD::mysql::st execute failed: Duplicate entry '388-73' for key
'PRIMARY' [for Statement \"INSERT INTO `search_marc_to_field` ( `facet`,
`search_field_id`, `search_marc_map_id`, `sort`, `suggestible`) VALUES (
?, ?, ?, ?, ? )\" with ParamValues: 0='', 1='73', 2='388', 3=undef,
4=''] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line
1834.\nDBIx::Class::Storage::DBI::_dbh_execute(): Duplicate entry
'388-73' for key 'PRIMARY' at /home/koha/Koha/Koha/SearchField.pm line
38"

This patch fixes this, by first deleting all entries, then adding the
default ones.

If a subroutine says reset_elasticsearch_mappings(), I expect it to
reset the elasticsearch mappings without errors.  When writing tests it
is better to call that one subroutine reset_elasticsearch_mappings
instead of the bunch of code in
admin/searchengine/elasticsearch/mappings.pl?op=reset_confirmed
Also this promotes code reuse.

TEST PLAN:

a. perl -e 'use Koha::SearchEngine::Elasticsearch; Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings'
b. Run misc/devel/populate_db.pl on an already populated DB and you eventually
face this problem.

After this patch, step a. works.

This patch is adapted from the original patch made by Olli-Antti
Kivilahti <olli-antti.kivilahti@jns.fi>.

Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-01-10 16:20:29 +00:00
..
searchengine/elasticsearch Bug 17885: Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws DBD::mysql Duplicate entry exceptions 2020-01-10 16:20:29 +00:00
add_user_search.pl Bug 15758: Koha::Libraries - Remove GetBranches 2016-09-08 14:36:03 +00:00
additional-fields.pl Bug 15774: (QA follow-up) Fix use statemenets 2019-03-07 20:37:06 +00:00
admin-home.pl Bug 17047: add a dedicated page for Mana setup 2019-01-23 14:39:26 +00:00
adveditorshortcuts.pl Bug 21411: Address QA concerns 2019-05-10 18:59:39 +00:00
aqbudgetperiods.pl Bug 10577: (QA follow-up) Remove bad call signature 2019-03-28 12:46:14 +00:00
aqbudgets.pl Bug 22786: Prevent fund creation for locked budgets 2019-09-06 13:17:47 +01:00
aqcontract.pl Bug 19992: use Modern::Perl in Admin perl scripts 2018-02-05 09:45:46 -03:00
aqplan.pl Bug 21137: Replace USER_INFO with logged_in_user 2018-08-14 12:43:10 +00:00
audio_alerts.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
auth_subfields_structure.pl Bug 21706: (follow-up) Fix subfield delete button 2018-11-12 16:39:50 -03:00
auth_tag_structure.pl Bug 21706: (follow-up) remove unused template params 2018-11-12 16:39:04 -03:00
authorised_values.pl Bug 23272: (RM followup) Fix edit action 2019-09-27 12:56:13 +01:00
authtypes.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
biblio_framework.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
branch_transfer_limits.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
branches.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
cash_registers.pl Bug 23321: Allow setting of branch default 2019-09-23 11:39:22 +01:00
categories.pl Bug 10796: Handle can_change_password on the staff interface 2019-04-12 02:32:07 +00:00
check_budget_parent.pl Bug 19992: use Modern::Perl in Admin perl scripts 2018-02-05 09:45:46 -03:00
check_parent_total.pl Bug 19992: use Modern::Perl in Admin perl scripts 2018-02-05 09:45:46 -03:00
checkmarc.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
cities.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
classsources.pl Bug 15836: Mark C4::ClassSource subs DEPRECATED 2018-11-13 15:18:22 +00:00
clone-rules.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
columns_settings.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
columns_settings.yml Bug 20194: Display both biblioitems.itemtype and items.itype in circulation screens 2019-11-03 07:50:19 +00:00
currency.pl Bug 7651: Add a new permission for managing currencies and exchange rates 2018-07-18 17:45:21 +00:00
debit_types.pl Bug 23049: (follow-up) Types should not be deletable 2019-10-24 17:25:03 +01:00
didyoumean.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
edi_accounts.pl Bug 21605: (follow-up) Simple ternary boolean to number conversion 2019-01-08 13:58:10 +00:00
edi_ean_accounts.pl Bug 21417: EDI ordering fails when basket and EAN libraries do not match 2018-10-09 11:54:08 +00:00
import_export_framework.pl Bug 23398: Disable the XML import/export format for biblio framework 2019-11-08 12:51:16 +00:00
item_circulation_alerts.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
items_search_field.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
items_search_fields.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
itemtypes.pl Bug 23772: Revert to passing itemtype objects to the template 2019-10-15 14:10:07 +01:00
koha2marclinks.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
library_groups.pl Bug 22284: Add new checkbox in Library Groups 2020-01-03 12:58:02 +00:00
localization.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
marc_subfields_structure.pl Bug 23309: Use Koha::MarcSubfieldStructures to create to subfields 2019-08-15 09:07:38 +01:00
marctagstructure.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
matching-rules.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
oai_set_mappings.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
oai_sets.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
overdrive.pl Bug 21082: Update OverDrive authentication method 2018-10-09 11:04:23 +00:00
patron-attr-types.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
preferences.pl Bug 24170: Fix sysprefs search result order 2019-12-13 14:05:17 +00:00
printers.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
share_content.pl Bug 23075: Do not 'Send' if the url is not correct 2019-11-06 17:05:18 +00:00
smart-rules.pl Bug 18930: (follow-up) Amend Koha::RefundLostItemFeeRules->find 2019-07-15 11:28:00 +01:00
sms_providers.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
sru_modmapping.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
systempreferences.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
transport-cost-matrix.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
usage_statistics.pl Bug 14391: Add granular permissions to the administration module 2018-11-07 12:29:32 +00:00
z3950servers.pl Bug 23242: Fix insert of Z3950 servers with strict SQL modes 2019-08-16 11:39:24 +01:00