Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -md command line param to set migrationsDir property #449

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

haxwell
Copy link

@haxwell haxwell commented Aug 10, 2024

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 the migrate-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
  • [ x] npm test passes and has 100% coverage
  • [ x] README.md is updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant