forked from hemantapkh/TorrentHunt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmigrations.py
79 lines (60 loc) · 2.32 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sqlite3
import os, json
config = json.load(open('src/config.json'))
magnetDatabase = config['magnetDatabase']
database = config['database']
input1 = input('Do you want to run migration for magnet link database? Y/[n]: ')
if input1 == 'y':
if os.path.exists(magnetDatabase):
os.remove(magnetDatabase)
print('[-] Database already exists. Deleting it.')
conn = sqlite3.connect(magnetDatabase)
print('[+] Magnetlink Database opened successfully.')
conn.execute('''CREATE TABLE data
(hash TEXT PRIMARY KEY COLLATE NOCASE,
title TEXT,
magnetlink TEXT
);''')
print('[+] Table data created successfully.')
conn.execute('''CREATE TABLE wishlist
(wishlistId INT PRIMARY KEY,
ownerId INT,
hash TEXT
);''')
print('[+] Table wishlist created successfully.')
conn.close()
input1 = input('Do you want to run migration for Torrent Hunt database? Y/[n]: ')
if input1 == 'y':
if os.path.exists(database):
os.remove(database)
print('[-] Database already exists. Deleting it.')
conn = sqlite3.connect(database)
print('[+] Database opened successfully.')
conn.execute('''CREATE TABLE users
(UserId INTEGER PRIMARY KEY,
date STRING NOT NULL,
referrer TEXT
);''')
print('[+] Table users created successfully.')
conn.execute('''CREATE TABLE groups
(UserId INTEGER PRIMARY KEY,
userName TEXT,
date STRING NOT NULL
);''')
print('[+] Table users created successfully.')
conn.execute('''CREATE TABLE settings
(ownerId INTEGER PRIMARY KEY,
language TEXT DEFAULT "english",
defaultSite TEXT DEFAULT "piratebay",
defaultMode TEXT DEFAULT "link",
restrictedMode INTEGER DEFAULT 1
);''')
print('[+] Table settings 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.')
conn.close()