-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbInit.js
62 lines (54 loc) · 1.74 KB
/
dbInit.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const Sequelize = require("sequelize");
// Create connection
const sequelize_osu = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
logging: false,
storage: "./database/osu.sqlite",
});
const sequelize_roles = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
logging: false,
storage: "./database/roles.sqlite",
});
const sequelize_birthdays = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
logging: false,
storage: "./database/birthdays.sqlite",
});
require("./models/Osu")(sequelize_osu, Sequelize.DataTypes);
const RolesDB = require("./models/Roles")(sequelize_roles, Sequelize.DataTypes);
require("./models/Birthdays")(sequelize_birthdays, Sequelize.DataTypes);
const force = process.argv.includes("--force") || process.argv.includes("-f");
sequelize_osu
.sync({ force })
.then(async () => {
console.log("Osu Database Synced");
sequelize_osu.close();
})
.catch(console.error);
sequelize_roles
.sync({ force })
.then(async () => {
const roles = [
RolesDB.upsert({ emote: "🎨", role: "Artist" }),
RolesDB.upsert({ emote: "🎮", role: "Free Games" }),
RolesDB.upsert({ emote: "💮", role: "NSFW" }),
RolesDB.upsert({ emote: "💻", role: "Programmer" }),
RolesDB.upsert({ emote: "🎬", role: "Animator" }),
RolesDB.upsert({ emote: "📹", role: "Streamer" }),
];
await Promise.all(roles);
console.log("Roles Database Synced");
sequelize_roles.close();
})
.catch(console.error);
sequelize_birthdays
.sync({ force })
.then(async () => {
console.log("Birthdays Database Synced");
sequelize_birthdays.close();
})
.catch(console.error);