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 multiple migration directories for up and down #161

Closed
wants to merge 1 commit into from

Conversation

nanodocumet
Copy link

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:

  • Production: db-migrate up -m schema
  • Development: 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.

@wzrdtales
Copy link
Member

closed in favour of scoped migrations

Note: maybe adding ability to run multiple scopes within one command

@wzrdtales wzrdtales closed this Aug 18, 2015
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.

None yet

2 participants