feat(importers): add copyRecords tool for importing individual records#1817
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Something I've wanted for a long time but couldn't be bothered with until now.
To import sample records to a dev db we've only had the importer tool's
copywhelkcommand, which takes a file with a list of IDs (and optionally a list of types to copy). This is mainly intended for the initial run when (re)creating a dev db.copywhelkredenormalizes the entire db and doesn't reindex on its own.The use case this PR solves is: "I have an existing dev database and I just want to quickly import one or a few specific records and their dependencies/dependers from the prod db (and redenormalize+index only what's necessary)". Et voilà:
cd importers/ ../gradlew jarTo import a couple of records by short ID, including their version history and holdings (if any):
java -Dxl.secret.properties=../secret.properties -jar build/libs/xlimporter.jar copyRecords --copy-versions --include-items ../temp_source_secret.properties 4ngh2qhg49jhnp4 vhsxx8rks82lgtn5By IRI:
java -Dxl.secret.properties=../secret.properties -jar build/libs/xlimporter.jar copyRecords --copy-versions --include-items ../temp_source_secret.properties https://libris.kb.se/4ngh2qhg49jhnp4Where
temp_source_secret.propertiescontains the details for the source database (e.g. qa/stg/prod readonly...). Just like withcopywhelk.--overwrite-existingcan also be specified. In that case the specified record will be updated with the contents of the source version (but then version history is not copied).