-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.js
48 lines (37 loc) · 1.22 KB
/
update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import DotEnv from 'dotenv';
import Prompt from 'prompt';
import User from './app/model/user';
import Content from './app/model/content';
import Session from './app/model/session';
DotEnv.config();
Prompt.start();
const Schema = {
properties: {
continue: {
description: 'Continue?',
required: true,
default: 'Y',
},
},
};
console.log('\x1b[47m\x1b[35m', 'ribbon Update', '\x1b[0m');
console.log('\x1b[47m\x1b[35m', 'Note that this upgrade script will only work on ribbon 2018.9.17 or older.', '\x1b[0m');
/*
* Script for future use.
*/
Prompt.get(Schema, async (prompt_err, prompt) => {
if (prompt.continue.toLowerCase() === 'y') {
await User.updateMany({}, { group: 1 }, { multi: true });
await Content.updateMany({}, { content_offset: 0 }, { multi: true });
/*
* Remove all existing sessions. With the change in usergroup, everyone has to log in again.
*/
await Session.deleteMany({});
console.log('\x1b[42m\x1b[30m', 'Update successful.', '\x1b[0m');
console.log('\x1b[42m\x1b[30m', 'Restart ribbon to implement changes.', '\x1b[0m');
process.exit();
} else {
console.log('\x1b[41m\x1b[37m', 'Update cancelled.', '\x1b[0m');
process.exit();
}
});