Skip to content

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