Add multiple migration directories for up and down #161
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.
Note: There are no tests at this point; I am having a lot of issues installing the dev dependencies. I have been using
npm install --dev db-migrate
and I get a lot of "Error: ENOENT, lstat" error messages.As of now, db-migrate reads migration files from a single directory when doing ups/down. This commit adds the capability to include a set of directories, separated by commas, when doing ups/down. This way, you can have greater control of what migrations could run for different environments. Migrations are merged into a single list and sorted by timestamp.
Example:
migrations/1001-create-users-table
migrations/1040-create-logs-table
post_migrations/1005-create-groups-table
After running
db-migrate up -m migrations,post_migrations
, the above migrations will run in this order:migrations/1001-create-users-table
post_migrations/1005-create-groups-table
migrations/1040-create-logs-table
Other example:
schema/1001-create-users-table
debug/1005-create-debugging-table
You might want to run the following commands depending on your environment:
db-migrate up -m schema
db-migrate up -m schema,debug
This commit adds an extra column, called
group
, to the migrations table. Eventually there will be a need to check if the column exists if this happens to be executed against an existing installation. This extra check will make the change backwards compatible. Let me know if you still want me to do this, should not be complicated. In my case, I am starting fresh, so, I don't need this change. The help text in db-migrate file in bin might need to be updated too.