Skip to content

Commit

Permalink
fix: add upgrade step for missing stopwords registry entries (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
remdub authored Feb 7, 2024
1 parent ac95eca commit 38dcf94
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
9.2.3 (unreleased)
------------------

- Nothing changed yet.
- Add upgrade step for missing stopwords registry entries [remdub]


9.2.2 (2024-02-06)
Expand Down
2 changes: 1 addition & 1 deletion src/collective/solr/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>7</version>
<version>8</version>
<dependencies>
<dependency>profile-plone.app.registry:default</dependency>
<dependency>profile-plone.restapi:default</dependency>
Expand Down
14 changes: 14 additions & 0 deletions src/collective/solr/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,17 @@ def migrate_to_7(context):
registry_record.value = "content"
registry.records["collective.solr.tika_default_field"] = registry_record
logger.info("Migrated to version 7")

def migrate_to_8(context):
registry = getUtility(IRegistry)
if "collective.solr.stopwords_case_insensitive" not in registry.records:
registry_field = field.Bool(title=u"Stopwords are case insensitive")
registry_record = Record(registry_field)
registry_record.value = False
registry.records["collective.solr.stopwords_case_insensitive"] = registry_record
if "collective.solr.stopwords" not in registry.records:
registry_field = field.Text(title=u"Stopwords in the format of stopwords.txt")
registry_record = Record(registry_field)
registry_record.value = ""
registry.records["collective.solr.stopwords"] = registry_record
logger.info("Migrated to version 8")
10 changes: 10 additions & 0 deletions src/collective/solr/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@
profile="collective.solr:default"
/>

<genericsetup:upgradeStep
title="Upgrade to collective.solr 8"
description="Add stopwords registry entries"
source="7"
destination="8"
handler=".setuphandlers.migrate_to_8"
sortkey="1"
profile="collective.solr:default"
/>

</configure>

0 comments on commit 38dcf94

Please sign in to comment.