Permalink
Browse files

Migrating downwards should set version one lower

Currently if one migrates downwards, the version is set to the last down migration ran.

Instead, it should be the new current version.
  • Loading branch information...
1 parent 799a50a commit d92a8c9788774ee989ed5424b9279cbd2c8c04c5 @pixelcort pixelcort committed Aug 3, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/persistence.migrations.js
@@ -161,9 +161,9 @@ if(!window.persistence) { // persistence.js not loaded!
this.actions = [];
};
- Migration.prototype.executeActions = function(callback) {
+ Migration.prototype.executeActions = function(callback, customVersion) {
var actionsToRun = this.actions;
- var version = this.version;
+ var version = (customVersion!==undefined) ? customVersion : this.version;
persistence.transaction(function(tx){
function nextAction() {
@@ -186,7 +186,7 @@ if(!window.persistence) { // persistence.js not loaded!
Migration.prototype.down = function(callback) {
if (this.body.down) this.body.down.apply(this);
- this.executeActions(callback);
+ this.executeActions(callback, this.version-1);
}
Migration.prototype.createTable = function(tableName, callback) {

0 comments on commit d92a8c9

Please sign in to comment.