-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb-migrations.js
More file actions
46 lines (40 loc) · 1.45 KB
/
db-migrations.js
File metadata and controls
46 lines (40 loc) · 1.45 KB
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
const { Client: PGClient } = require('pg')
const pgClient = new PGClient({ host: process.env.database, user: 'postgres', port: 5433, password: 'admin', database: 'starie' })
pgClient.connect()
async function MakeMigrations() {
console.log("Make migrations")
// enabled modules table by guild
await pgClient.query(`CREATE TABLE IF NOT EXISTS enabled_modules (
guild_id BIGINT NOT NULL,
module_name VARCHAR(255) NOT NULL,
PRIMARY KEY (guild_id, module_name)
)`);
// leveling table by guild
await pgClient.query(`CREATE TABLE IF NOT EXISTS leveling (
guild_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
xp BIGINT NOT NULL,
level BIGINT NOT NULL,
PRIMARY KEY (guild_id, user_id)
)`);
// guild settings table
await pgClient.query(`CREATE TABLE IF NOT EXISTS guild_settings (
guild_id BIGINT NOT NULL,
setting_name VARCHAR(255) NOT NULL,
setting_value VARCHAR(255) NOT NULL,
PRIMARY KEY (guild_id, setting_name)
)`);
// tracked apis table
await pgClient.query(`CREATE TABLE IF NOT EXISTS tracked_apis (
id SERIAL NOT NULL,
name VARCHAR(255) NOT NULL,
guild_id BIGINT NOT NULL,
channel_id BIGINT NOT NULL,
message_id BIGINT NOT NULL,
api_link VARCHAR(255) NOT NULL,
api_key VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)`);
pgClient.end();
}
module.exports = MakeMigrations;