-
Notifications
You must be signed in to change notification settings - Fork 55
/
migrations.py
61 lines (50 loc) · 1.75 KB
/
migrations.py
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
import sqlite3
import os, json
config = json.load(open('src/config.json'))
database = config['database']
if os.path.exists(database):
confirm = input('Database already exists. Do you want to delete it and create a new one? (y/[N]): ')
if confirm == 'y':
os.remove(database)
print('[-] Database already exists. Deleting it.')
else:
print('[-] Exiting.')
exit()
conn = sqlite3.connect(database)
print('[+] Database opened successfully.')
conn.execute('''CREATE TABLE users
(UserId INTEGER PRIMARY KEY,
date STRING NOT NULL
);''')
print('[+] Table users created successfully.')
conn.execute('''CREATE TABLE settings
(ownerId INTEGER PRIMARY KEY,
language TEXT DEFAULT "english",
playlist TEXT DEFAULT "m3u",
githubId TEXT DEFAULT 0,
totalRefer INTEGER DEFAULT 0,
defaultAcId INTEGER
);''')
print('[+] Table settings created successfully.')
conn.execute('''CREATE TABLE accounts
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
accountId INTEGER NOT NULL,
ownerId INTEGER NOT NULL,
userName TEXT NOT NULL,
token TEXT NOT NULL,
email TEXT,
password TEXT,
cookie TEXT,
isPremium INTEGERL,
invitesRemaining INTEGER,
timestamp INTEGER
);''')
print('[+] Table accounts created successfully.')
conn.execute('''CREATE TABLE flood
(ownerId INTEGER PRIMARY KEY,
warned INTEGER DEFAULT 0,
lastMessage INTEGER DEFAULT 0,
blockTill INTEGER DEFAULT 0
);''')
print('[+] Table flood created successfully.')