Passed
Push — master ( dcd1eb...4f7f97 )
by Cyb3r
02:51 queued 01:44
created

bot.utils.tables   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 105
rs 10
c 0
b 0
f 0
wmc 0
1
"""List of tables that are created
2
---
3
    Tables:
4
    ---
5
        schools: Table for school roles.
6
            school {text}: name of the school
7
            region {text}: name of the region where the school is
8
            color {int}: hex code of the color **
9
            id {bigint}: Discord ID of the role
10
            added_by {text}: Username who created the school **
11
            added_by_id {bigint}: Discord ID of the member who created the school
12
13
        bot_admins: Table for users that are bot admins.
14
            id {bigint}: Discord ID of admin
15
            name {text}: username of the admin
16
17
        admin_channels: Table for discord channels that are for admin.
18
            name {text}: Name of the channel
19
            id {bigint}: Discord ID of the channel
20
            log {bool}: If the channel is a logging channel or not
21
22
        regions: Table for region roles
23
            name {text}: Name of the region
24
            id {bigint}: Discord ID of the role
25
26
        errors: Table of information about errors
27
            id {smallint}: ID for the error. Each number is random.
28
            message {text}: The message that was sent causing the error.
29
            command {text}: The command that was triggered to run
30
            error {text}: The error that occurred
31
            time {timestamp}: The time when the error occurred.
32
            ack {bool}: Error has been acknowledged by an admin
33
34
        keys: Table for misc information stored.
35
            key {text}: Name of the value
36
            value {text}: The value
37
38
        messages: Table for storing messages
39
            name {text}: Name of the message
40
            message {text}: Content of the message
41
42
        reports: Table for reports
43
            id {int}: ID of the report
44
            name {text}: Discord member name of reporter
45
            name_id {bigint}: Discord member ID reporter
46
            message {text}: Text of the report
47
            time {timestamp}: Time of the report
48
"""
49
tables = [
50
    """
51
CREATE TABLE IF NOT EXISTS schools(
52
school text UNIQUE NOT NULL DEFAULT '',
53
region text NOT NULL DEFAULT '',
54
color int NOT NULL DEFAULT 0,
55
id bigint NOT NULL DEFAULT 0,
56
added_by text NOT NULL DEFAULT '',
57
added_by_id bigint NOT NULL DEFAULT 0,
58
PRIMARY KEY (school)
59
);""",
60
    """
61
CREATE TABLE IF NOT EXISTS bot_admins(
62
id bigint UNIQUE NOT NULL DEFAULT 0,
63
name text NOT NULL DEFAULT '',
64
PRIMARY KEY (name)
65
);
66
""",
67
    """
68
CREATE TABLE IF NOT EXISTS admin_channels(
69
name text NOT NULL DEFAULT '',
70
id bigint NOT NULL DEFAULT 0,
71
log bool DEFAULT False,
72
PRIMARY KEY (name)
73
);
74
""",
75
    """
76
CREATE TABLE IF NOT EXISTS regions(
77
name text NOT NULL DEFAULT '',
78
id bigint NOT NULL DEFAULT 0,
79
PRIMARY KEY (name)
80
);
81
""",
82
    """
83
CREATE TABLE IF NOT EXISTS errors(
84
id smallint NOT NULL DEFAULT 0,
85
command text NOT NULL DEFAULT '',
86
message text NOT NULL DEFAULT '',
87
error text NOT NULL DEFAULT '',
88
time timestamptz NOT NULL,
89
ack bool NOT NULL DEFAULT FALSE,
90
PRIMARY KEY (id)
91
);""",
92
    """
93
CREATE TABLE IF NOT EXISTS keys(
94
key text NOT NULL DEFAULT '',
95
value text NOT NULL DEFAULT '',
96
PRIMARY KEY (key)
97
);""",
98
    """
99
CREATE TABLE IF NOT EXISTS messages(
100
name text NOT NULL DEFAULT '',
101
message text NOT NULL DEFAULT '',
102
PRIMARY KEY (name)
103
);""",
104
    """
105
CREATE TABLE IF NOT EXISTS reports(
106
id int NOT NULL DEFAULT 0,
107
name text NOT NULL DEFAULT '',
108
name_id bigint NOT NULL DEFAULT 0,
109
message text NOT NULL DEFAULT '',
110
time timestamptz NOT NULL,
111
PRIMARY KEY(id)
112
);""",
113
]
114