Add migration scripts to export concepts and import them to another Leaf instance #12
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.
This pull request aims to contribute the following assets to streamline concept migration from one Leaf instance to another:
generate_inserts.sh
, which exports theapp.Specialization
,app.Concept
,app.ConceptSqlSet
, andapp.SpecializationGroup
tables usingsp_generate_inserts
, then copies the resulting INSERT statements into the Docker container specified by the argument provided toconcept-cloner.sh
. It also fixes up the output so that any single quotes are replaced with backticks, and trailing whitespace is removed when present inside of quoted strings.concept-cloner.sh
into the Docker container, deletes old concepts and relationship information, then pushes the new concepts using theinsert_concepts.sh
shell script.sqlcmd
to remove and replace the required concept and specialization data.sqlcmd
to runsp_generate_inserts
to export the required tables, and usessed
to fix up the output to remove trailing whitespace.The usage is simple. The scripts use the Docker service name and extract the container name from
docker compose ps -a
, since it may be easier to recall the service name versus the container name:In addition, the R script used to produce SQL tables from
data.frame
objects is also contributed here asgenerate_inserts.R
, based on code posted here.Note that the original version of the R functions produces output that has
<SQL>
in the header line, which must be removed. Additionally, the resulting statements are not terminated with semicolons, and single quotes are used where backticks may be necessary. This can be fixed for now usingsed
like so: