Skip to content

Instantly share code, notes, and snippets.

@mcwhittemore
Created April 15, 2014 12:29
Show Gist options
  • Select an option

  • Save mcwhittemore/10728524 to your computer and use it in GitHub Desktop.

Select an option

Save mcwhittemore/10728524 to your computer and use it in GitHub Desktop.
stats about your migrations
var migrations = [/* to be filled with paths to node-db-migrate modules */]
var total = migrations.length;
var ups = 0;
var downs = 0;
var upMTO = 0;
var downMTO = 0;
var uu = [];
var dd = [];
for(var i=0; i<total; i++){
var m = require(migrations[i]);
var up = (m.up || {}).toString();
var down = (m.down || {}).toString();
var nUp = (up.match(/db\./g) || []).length;
var nDown = (down.match(/db\./g) || []).length;
upMTO += nUp > 1 ? 1 : 0;
downMTO += nDown > 1 ? 1 : 0;
ups+=nUp;
downs+=nDown;
uu.push(nUp);
dd.push(nDown);
}
var ss = function(a, b){
return a-b;
}
uu = uu.sort(ss);
dd = dd.sort(ss);
var part = 100/total;
console.log("Total:", total);
console.log("Ups:", ups, part*ups);
console.log("Downs:", downs, part*downs);
console.log("Ups MTO:", upMTO, part*upMTO);
console.log("Downs MTO:", downMTO, part*downMTO);
console.log("MUp", uu[75]);
console.log("MDown", dd[75]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment