Added NEX account migration script

This commit is contained in:
Jonathan Barrow 2022-09-28 18:46:36 -04:00
parent 7991038f8a
commit ad3b62dd9c
No known key found for this signature in database
GPG key ID: E86E9FE9049C741F

View file

@ -0,0 +1,32 @@
const database = require('../../src/database');
const { NEXAccount } = require('../../src/models/nex-account');
database.connect().then(async function () {
const nexAccounts = await NEXAccount.find({});
const nexAccounts3DS = await NEXAccount.find({ device_type: '3ds' });
const nexAccountsWiiU = await NEXAccount.find({ device_type: 'wiiu' });
console.log('NEX accounts:', nexAccounts.length);
console.log('NEX accounts (3DS):', nexAccounts3DS.length);
console.log('NEX accounts (WiiU):', nexAccountsWiiU.length);
for (const nexAccount of nexAccounts) {
let deviceType = '';
if (nexAccount.owning_pid !== nexAccount.pid) {
// 3DS account
deviceType = '3ds';
} else {
// WiiU account
deviceType = 'wiiu';
}
nexAccount.device_type = deviceType;
await nexAccount.save();
}
console.log('Migrated accounts');
process.exit(0);
});