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

PlanMigration returns error when no safe migration is possible #103

Merged
merged 2 commits into from
Jul 4, 2018

Conversation

ironsmile
Copy link
Contributor

As discussed in #43 and #85 there are problems when the database contains migrations which are not part of the current plan. Up to this PR sql-migrate was just ignoring such cases and hoped for the best.

The PR adds a new error type PlanError and uses it when a mismatch between the database migrations and the current source migrations is found. This way one would be able to ignore this error while using sql-migrate as a library if need be.

As discussed in GitHub issue rubenv#43 the PlanMigration function would not
allow running migrations when the there are already applied migrations
in the database which are not part of the migration source. In such
cases the user have to decide what to do.

This also fixes a bug where running the `up` migration would result in
success exit status while nothing has been done.
This removes the need to create and remove files in the filesystem
during testing. Less moving parts is always better I would think.
@rubenv
Copy link
Owner

rubenv commented Jul 4, 2018

Bit late to come back to this, but looks very good to me, thanks a lot!

@rubenv rubenv merged commit 3f452fc into rubenv:master Jul 4, 2018
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.

2 participants