-
Notifications
You must be signed in to change notification settings - Fork 11
/
schemas.js
98 lines (79 loc) · 2.15 KB
/
schemas.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var schema = {};
schema.defs = {};
// this table should only have one value in it
schema.defs.version = `
version (
vID INTEGER PRIMARY KEY AUTOINCREMENT,
version TEXT NOT NULL
)`;
schema.defs.channels = `
channels (
chID INTEGER PRIMARY KEY AUTOINCREMENT,
discordchid TEXT UNIQUE NOT NULL,
guildid TEXT NOT NULL,
limitedto INTEGER NOT NULL DEFAULT 0,
UNIQUE(discordchid, guildid)
)`;
// a kid in different guilds may have different permission levels
schema.defs.discokids = `
discokids (
dkidID INTEGER PRIMARY KEY AUTOINCREMENT,
permission INTEGER NOT NULL DEFAULT 0,
discordid TEXT NOT NULL,
guildid TEXT NOT NULL,
UNIQUE(discordid, guildid)
)`;
// checking for metareqs existence should only be taken care of in dbfuncs.js
schema.defs.metareqs = `
metareqs (
mreqID INTEGER PRIMARY KEY AUTOINCREMENT,
budget INTEGER,
silentstart INTEGER,
silentend INTEGER,
discordkidID INTEGER NOT NULL,
channelID INTEGER NOT NULL,
FOREIGN KEY (discordkidID) REFERENCES discokids(dkidID) ON DELETE CASCADE,
FOREIGN KEY (channelID) REFERENCES channels(chID) ON DELETE CASCADE,
UNIQUE(discordkidID, channelID)
)`;
// store as lowercase
// discordkidID and channelID are schema internal ID, not discord IDs
schema.defs.requirements = `
requirements (
reqID INTEGER PRIMARY KEY AUTOINCREMENT,
message TEXT,
name TEXT,
slotted INTEGER,
refine BLOB NOT NULL DEFAULT 65535,
broken INTEGER,
pricehigher INTEGER,
pricelower INTEGER,
buyers INTEGER,
enchant TEXT,
enchantlevel BLOB NOT NULL DEFAULT 31,
category TEXT,
stock INTEGER,
alias INTEGER NOT NULL DEFAULT 0,
metareqID INTEGER NOT NULL,
FOREIGN KEY (metareqID) REFERENCES metareqs(mreqID) ON DELETE CASCADE
)`;
// icon is for image purposes
// make sure everything lowercase
schema.defs.currentsnap = `
currentsnap (
currID INTEGER PRIMARY KEY AUTOINCREMENT,
snapid INTEGER UNIQUE NOT NULL,
icon TEXT,
name TEXT NOT NULL,
slots TEXT NOT NULL,
refine TEXT NOT NULL,
broken INTEGER NOT NULL,
price INTEGER NOT NULL,
buyers INTEGER NOT NULL,
enchant TEXT NOT NULL,
enchantlevel TEXT NOT NULL,
category TEXT NOT NULL,
stock INTEGER NOT NULL,
snapend INTEGER NOT NULL
)`;
module.exports = schema;