Created
February 17, 2016 20:58
-
-
Save StephanHoyer/3639e0553488a38e4faa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateTile(tile) { | |
if (tile.get('width')) { | |
tile.set('columnCount', (tile.get('width') + gutter) / columnToColumn); | |
} | |
tile.set('width', tile.get('columnCount') * columnToColumn - gutter); | |
return tile.save(); | |
} | |
function updateTiles() { | |
// this is called | |
return tileModel.fetchAll().then(function(tiles) { | |
// this is never called | |
return tiles.mapThen(updateTile); | |
}); | |
} | |
exports.up = function(knex) { | |
return knex.schema.table('tile', function (table) { | |
table.integer('width'); | |
}).then(updateTiles).then(function() { | |
return knex.schema.table('tile', function (table) { | |
table.dropColumn('column_count'); | |
}); | |
}); | |
}; | |
exports.down = function(knex) { | |
return knex.schema.table('tile', function (table) { | |
table.integer('column_count'); | |
}).then(updateTiles).then(function() { | |
return knex.schema.table('tile', function (table) { | |
table.dropColumn('width'); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment