Files
habitica/migrations/archive/2017/account-transfer.js
Sabe Jones 2ba74f1645 chore(migrations): move various files to archive
and remove erroneous comment bars
2024-02-05 15:34:53 -06:00

38 lines
1.1 KiB
JavaScript

/*
let migrationName = 'AccountTransfer';
let authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
let authorUuid = ''; // ... own data is done
*/
/*
* This migraition will copy user data from prod to test
*/
import monk from 'monk'; // eslint-disable-line import/no-extraneous-dependencies
const connectionString = '';
const Users = monk(connectionString).get('users', { castIds: false });
export default async function accountTransfer () {
const fromAccountId = '';
const toAccountId = '';
const fromAccount = await Users.findOne({ _id: fromAccountId });
const toAccount = await Users.findOne({ _id: toAccountId });
const newMounts = { ...fromAccount.items.mounts, ...toAccount.items.mounts };
const newPets = { ...fromAccount.items.pets, ...toAccount.items.pets };
const newBackgrounds = { ...fromAccount.purchased.background, ...toAccount.purchased.background };
await Users.update({ _id: toAccountId }, {
$set: {
'items.pets': newPets,
'items.mounts': newMounts,
'purchased.background': newBackgrounds,
},
})
.then(result => {
console.log(result);
});
}