mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Group migrations (#8528)
* Added create group migration * Add migration for unlimited group subscription * Add migration to update group members with group plans * Added error catch * Added comments
This commit is contained in:
33
migrations/groups/add-unlimited-subscription.js
Normal file
33
migrations/groups/add-unlimited-subscription.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var migrationName = 'AddUnlimitedSubscription';
|
||||
var authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
|
||||
var authorUuid = ''; //... own data is done
|
||||
|
||||
/*
|
||||
* This migrations will add a free subscription to a specified group
|
||||
*/
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
|
||||
// @TODO: this should probably be a GroupManager library method
|
||||
async function addUnlimitedSubscription (groupId) {
|
||||
let group = await Group.findById(groupId);
|
||||
|
||||
group.purchased.plan.customerId = "group-unlimited";
|
||||
group.purchased.plan.dateCreated = new Date();
|
||||
group.purchased.plan.dateUpdated = new Date();
|
||||
group.purchased.plan.paymentMethod = "Group Unlimited";
|
||||
group.purchased.plan.planId = "group_monthly";
|
||||
group.purchased.plan.dateTerminated = null;
|
||||
// group.purchased.plan.owner = ObjectId();
|
||||
group.purchased.plan.subscriptionId = "";
|
||||
|
||||
return group.save();
|
||||
};
|
||||
|
||||
module.exports = async function addUnlimitedSubscriptionCreator () {
|
||||
let groupId = process.argv[2];
|
||||
|
||||
if (!groupId) throw Error('Group ID is required');
|
||||
|
||||
let result = await addUnlimitedSubscription(groupId)
|
||||
};
|
||||
Reference in New Issue
Block a user