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

Raise an error when missing (pending) migrations are detected #279

Closed
mfridman opened this issue Oct 16, 2021 · 1 comment
Closed

Raise an error when missing (pending) migrations are detected #279

mfridman opened this issue Oct 16, 2021 · 1 comment

Comments

@mfridman
Copy link
Collaborator

mfridman commented Oct 16, 2021

The default state in goose is to ignore out-of-order migrations. If you subscribe to hybrid versioning approach then this will not affect you because out-of-order migrations aren't possible.

The intended behaviour for goose should be to detect older, unapplied, migrations and error if any are found.

To illustrate an example, suppose migration 1 and 4 are applied and then version 2 and 3 are introduced. Today goose will ignore version 2 and 3.

Database: goose_db_version

| version_id | is_applied |
|------------|------------|
|          0 | t          |
|          1 | t          |
|          4 | t          |

commands below abbreviated

$ goose status 
Applied At                  Migration
=======================================
Sat Oct 16 12:56:26 2021 -- 00001_a.sql
Pending                  -- 00002_b.sql
Pending                  -- 00003_c.sql
Sat Oct 16 12:56:26 2021 -- 00004_d.sql

$ goose up
goose: no migrations to run. current version: 4

$ goose up-by-one
goose: no migrations to run. current version: 4
goose run: no next version found

The fix is to return an error if pending migrations are detected. This will be the default.

After this PR is merged In a single PR I'll add support for out-of-order migrations as described #262. That way folks are not blocked and have a flag (or option) to apply migrations.

EDIT: I suppose there will be some people that are happy to ignore those pending migrations, not to be confused with the folks that would like to apply out-of-order migrations. For the former we could add a "disable validation" or something. But I'd like for someone to raise an issue for that use-case.

@mfridman
Copy link
Collaborator Author

Fixed by #280

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

No branches or pull requests

1 participant