-
Notifications
You must be signed in to change notification settings - Fork 14
/
dbmodels.py
51 lines (34 loc) · 1.61 KB
/
dbmodels.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
from playhouse.db_url import connect
from playhouse.sqlite_ext import *
from decouple import config
db_proxy = Proxy()
db = connect(config("DATABASE_URL", default='sqlite:///tacoDB.sqlite', cast=str), autorollback=True)
db_proxy.initialize(db)
class Chats(Model): # chats-model is here for future updates only
cid = BigIntegerField()
invited_by = BigIntegerField()
less = BooleanField(default=False)
autohide = BooleanField(default=False)
autohide_delay = IntegerField(default=15)
mids = JSONField(null=True,
default=[])
class Meta:
database = db
if not Chats.table_exists(): # creating chats if not present
db.create_tables([Chats])
class Tacos(Model): # taco-model stores balances and chat-related things
chat = BigIntegerField()
taco_balance = JSONField(null=True,
default={})
class Meta:
database = db
if not Tacos.table_exists(): # creating tacos if not present
db.create_tables([Tacos])
class Usernames(Model): # username-model is here only for /tacotop
uid = BigIntegerField()
name = CharField()
username = CharField(null=True)
class Meta:
database = db
if not Usernames.table_exists(): # creating usernames if not present
db.create_tables([Usernames])