Skip to content

Commit

Permalink
feat(subscriptions): add free month script for users who canceled in …
Browse files Browse the repository at this point in the history
…old system
  • Loading branch information
lefnire committed May 6, 2014
1 parent b0eb12b commit 4990a6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
11 changes: 11 additions & 0 deletions migrations/freeMonth.js
Original file line number Diff line number Diff line change
@@ -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()
}}
)
22 changes: 17 additions & 5 deletions migrations/mysteryitems.js
Original file line number Diff line number Diff line change
@@ -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}
)
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});
}

0 comments on commit 4990a6d

Please sign in to comment.