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

Validating the migration ID exist in the list of migrations #21

Merged
merged 2 commits into from Dec 2, 2018

Conversation

tonytanger
Copy link
Contributor

@tonytanger tonytanger commented Nov 22, 2018

Return an error if the migration id passed that MigrateTo and RollbackTo does not exist in the list of migrations.

#20

Copy link
Contributor

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tonytanger, thanks for reporting the issue and opening this PR.

Can you please add a test case to check it returns this error if an inexistent migration ID is given?

gormigrate.go Outdated
@@ -164,6 +172,18 @@ func (g *Gormigrate) checkDuplicatedID() error {
return nil
}

func (g *Gormigrate) checkIDExist(migrationID string) error {
if migrationID == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... maybe we should remove this if and just return the error if migrationID is ""?

I don't think rollbackTo should rollback all migration in any circumstance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the check to allow empty migration ID. This also meant changes to Migrate so it doesn't migrate to an empty string, but to the last migration in the list, which I think is same semantics as before.

@andreynering
Copy link
Contributor

andreynering commented Dec 2, 2018

@tonytanger Seems great. Thanks!

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