Add -md command line param to set migrationsDir property #449
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.
Adds a command line parameter to set the
migrationsDir
property.Imagine a program which generates two types of migration scripts, 1) for schemas, and also 2) to insert test data. Initially, I was putting the two types in a single directory, but I ran into a problem in that the schema scripts need to be applied before the insert-test-datas, otherwise you may lose test data. My solution was to enforce the logic of "schemas-before-test-data" in the program, by creating a directory for each type of migration, and then calling the schemas to be
migrate-mongo up
'd first, and then the test-datas.However, the directory which migration scripts are read from/written to is determined by the
migrationDirs
property in themigrate-mongo-config.js
file. So to output to/read from the individual type directories, I would need to edit this file to refer to one or the other before calling migrate-mongo.It was easier modify migrate-mongo to accept a command line parameter, than to deal with programatically editing via awk/sed, the config file.
Checklist
npm test
passes and has 100% coverage