Skip to content

Resolve issue with Issue with calling persistence.migrate with no par… #175

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jaylagare
Copy link

Per documentation: persistence.migrate() to run migrations up to the most recent

I encountered an issue where calling persistence.migrate with no parameters didn't do anything. Checking the code of persistence.migrations.js, I found the problem where version is undefined and thus no migration is done and only the callback is called:
if (curVersion < version)
Migrator.migrateUpTo(version, callback);
else if (curVersion > version)
Migrator.migrateDownTo(version, callback);
else
callback();

Solution is to update code from:
migrate: function(version, callback) {
if ( arguments.length === 1) {
callback = version;
version = this.migrations.length-1;
}

to:
migrate: function(version, callback) {
if ( arguments.length === 1) {
callback = version;
}
if (arguments.lemgth <= 1) {
version = this.migrations.length-1;
}

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.

1 participant