From 4990a6d0e15e3b0032a0d8b4df3a70ef68fcc2e6 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Tue, 6 May 2014 10:13:33 -0600 Subject: [PATCH] feat(subscriptions): add free month script for users who canceled in old system --- migrations/freeMonth.js | 11 +++++++++++ migrations/mysteryitems.js | 22 +++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 migrations/freeMonth.js diff --git a/migrations/freeMonth.js b/migrations/freeMonth.js new file mode 100644 index 0000000000..36f320746c --- /dev/null +++ b/migrations/freeMonth.js @@ -0,0 +1,11 @@ +// mongo habitrpg ./node_modules/moment/moment.js ./migrations/freeMonth.js + +db.users.update( + {_id:''}, + {$set:{ + 'purchased.plan.customerId':'temporary', + 'purchased.plan.paymentMethod':'Stripe', + 'purchased.plan.planId':'basic_earned', + 'purchased.plan.dateTerminated': moment().add('month',1).toDate() + }} +) \ No newline at end of file diff --git a/migrations/mysteryitems.js b/migrations/mysteryitems.js index 54ac120600..4f7e4dd837 100644 --- a/migrations/mysteryitems.js +++ b/migrations/mysteryitems.js @@ -1,5 +1,17 @@ -db.users.update( - {'purchased.plan.customerId':{$ne:null}}, - {$push: {'purchased.plan.mysteryItems':{$each:['back_mystery_201404','headAccessory_mystery_201404']}}}, - {multi:true} -) \ No newline at end of file +var _id = ''; +var update = { + $push: { + 'purchased.plan.mysteryItems':{ + $each:['back_mystery_201404','headAccessory_mystery_201404'] + } + } +}; + +if (_id) { + // singular (missing items) + db.users.update({_id:_id}, update); +} else { + // multiple (once @ start of event) + db.users.update({'purchased.plan.customerId':{$ne:null}}, update, {multi:true}); +} +