Skip to content

Commit 298bcf7

Browse files
committed
updated migrations
1 parent fc994bf commit 298bcf7

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

migrations/add-console-type-to-nex-account.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@ const database = require('../dist/database');
22
const { NEXAccount } = require('../dist/models/nex-account');
33

44
database.connect().then(async function () {
5-
const nexAccounts = await NEXAccount.find({});
5+
const nexAccountsTotal = await NEXAccount.find({});
66
const nexAccounts3DS = await NEXAccount.find({ device_type: '3ds' });
77
const nexAccountsWiiU = await NEXAccount.find({ device_type: 'wiiu' });
8+
const nexAccountsToBeChanged = await NEXAccount.find({
9+
device_type: {
10+
$exists: false
11+
}
12+
});
813

9-
console.log('NEX accounts:', nexAccounts.length);
14+
console.log('NEX accounts (Total):', nexAccountsTotal.length);
1015
console.log('NEX accounts (3DS):', nexAccounts3DS.length);
1116
console.log('NEX accounts (WiiU):', nexAccountsWiiU.length);
17+
console.log('NEX accounts (To be changed):', nexAccountsToBeChanged.length);
1218

13-
for (const nexAccount of nexAccounts) {
14-
let deviceType = '';
15-
19+
for (const nexAccount of nexAccountsToBeChanged) {
1620
if (nexAccount.owning_pid !== nexAccount.pid) {
1721
// 3DS account
18-
deviceType = '3ds';
22+
nexAccount.device_type = '3ds';
1923
} else {
2024
// WiiU account
21-
deviceType = 'wiiu';
25+
nexAccount.device_type = 'wiiu';
2226
}
2327

24-
nexAccount.device_type = deviceType;
25-
2628
await nexAccount.save();
2729
}
2830

migrations/add-missing-friendcodes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ const database = require('../dist/database');
33
const { NEXAccount } = require('../dist/models/nex-account');
44

55
database.connect().then(async function () {
6-
const nexAccounts3DS = await NEXAccount.find({
6+
const nexAccountsToBeChanged = await NEXAccount.find({
77
device_type: '3ds',
88
friend_code: {
99
$exists: false
1010
}
1111
});
1212

13-
for (const nexAccount of nexAccounts3DS) {
13+
for (const nexAccount of nexAccountsToBeChanged) {
1414

1515
if (!nexAccount.friend_code) {
1616
const pid = nexAccount.pid;

0 commit comments

Comments
 (0)