Skip to content

Instantly share code, notes, and snippets.

@StephanHoyer
Created February 17, 2016 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanHoyer/3639e0553488a38e4faa to your computer and use it in GitHub Desktop.
Save StephanHoyer/3639e0553488a38e4faa to your computer and use it in GitHub Desktop.
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