mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
feat(subscriptions): add free month script for users who canceled in old system
This commit is contained in:
parent
b0eb12bb5f
commit
4990a6d0e1
2 changed files with 28 additions and 5 deletions
11
migrations/freeMonth.js
Normal file
11
migrations/freeMonth.js
Normal file
|
|
@ -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()
|
||||
}}
|
||||
)
|
||||
|
|
@ -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});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue