Modified: database.py
This commit is contained in:
parent
6121d5a3ff
commit
652ec5a242
19
database.py
19
database.py
|
@ -1,12 +1,13 @@
|
||||||
from peewee import DateTimeField, ForeignKeyField, Model, CharField, BigIntegerField, DateField
|
from peewee import Model
|
||||||
|
from peewee import BigIntegerField, CharField, DateTimeField, DateField, ForeignKeyField
|
||||||
from playhouse.db_url import connect
|
from playhouse.db_url import connect
|
||||||
|
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from config import db_url
|
from config import db_url
|
||||||
|
|
||||||
|
|
||||||
db = connect(db_url)
|
db = connect(db_url)
|
||||||
|
|
||||||
|
|
||||||
class WebUser(Model):
|
class WebUser(Model):
|
||||||
username = CharField()
|
username = CharField()
|
||||||
password_hash = CharField()
|
password_hash = CharField()
|
||||||
|
@ -15,29 +16,31 @@ class WebUser(Model):
|
||||||
db_table = "webusers"
|
db_table = "webusers"
|
||||||
database = db
|
database = db
|
||||||
|
|
||||||
|
|
||||||
class Member(Model):
|
class Member(Model):
|
||||||
user_id = BigIntegerField()
|
user_id = BigIntegerField()
|
||||||
first_name = CharField()
|
first_name = CharField()
|
||||||
username = CharField(null=True)
|
username = CharField(null=True)
|
||||||
|
|
||||||
role = CharField(default="member")
|
role = CharField(default="member")
|
||||||
|
|
||||||
warns = BigIntegerField(default=0)
|
warns = BigIntegerField(default=0)
|
||||||
|
|
||||||
joined = DateField(default=date.today())
|
joined = DateField(default=date.today())
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "members"
|
db_table = "members"
|
||||||
database = db
|
database = db
|
||||||
|
|
||||||
|
|
||||||
class Message(Model):
|
class Message(Model):
|
||||||
user = ForeignKeyField(Member,lazy_load=True)
|
user = ForeignKeyField(Member, lazy_load=True)
|
||||||
timestamp = DateTimeField(default=datetime.now())
|
timestamp = DateTimeField(default=datetime.now())
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "messages"
|
db_table = "messages"
|
||||||
database = db
|
database = db
|
||||||
|
|
||||||
|
|
||||||
def build_database():
|
def build_database():
|
||||||
db.create_tables([WebUser,Message])
|
db.create_tables([WebUser, Message])
|
||||||
|
|
Loading…
Reference in New Issue