Files
habitica/migrations/archive/2013/20131022_restore_ads.js
Matteo Pagliazzi 74ba55c20b Upgrade tests tools and lint migrations and scripts (part 2) (#9998)
* upgrade gulp-babel

* upgrade babel-eslint

* upgrade eslint-friendly-formatter

* start upgrading chai

* start to upgrade eslint

* restore skipped tests

* start to upgrqde monk

* fix linting and remove unused file

* fix mocha notifications, and common tests

* fix unit tests

* start to fix initrgration tests

* more integration tests fixes

* upgrade monk to latest version

* lint /scripts

* migrations: start moving to /archive unused migrations and run eslint with --fix

* lint migrations

* fix more integration tests

* fix test
2018-02-17 18:11:24 +01:00

12 lines
651 B
JavaScript

// node .migrations/20131022_restore_ads.js
let mongo = require('mongoskin');
let _ = require('lodash');
let dbBackup = mongo.db('localhost:27017/habitrpg?auto_reconnect');
let dbLive = mongo.db('localhost:27017/habitrpg2?auto_reconnect');
let count = 89474;
dbBackup.collection('users').findEach({$or: [{'flags.ads': 'show'}, {'flags.ads': null}]}, {batchSize: 10}, function (err, item) {
if (err) return console.error({err});
if (!item || !item._id) return console.error('blank user');
dbLive.collection('users').update({_id: item._id}, {$set: {'purchased.ads': false}, $unset: {'flags.ads': 1}});
if (--count <= 0) console.log('DONE!');
});