diff options
author | romangraef <roman.graef@gmail.com> | 2018-06-09 20:00:38 +0200 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-06-09 20:00:38 +0200 |
commit | e0d6c5ccdf6576aba56406455d9833de9626f7de (patch) | |
tree | d2082575a90e257111c8e79cb0f9afbc83376fd3 | |
parent | bb27efebb9ebb30e85e780758d259bcb72a699c4 (diff) | |
download | datapackmanagerapi-e0d6c5ccdf6576aba56406455d9833de9626f7de.tar.gz datapackmanagerapi-e0d6c5ccdf6576aba56406455d9833de9626f7de.tar.bz2 datapackmanagerapi-e0d6c5ccdf6576aba56406455d9833de9626f7de.zip |
database remodel
-rw-r--r-- | api/v1/db.py | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/api/v1/db.py b/api/v1/db.py index 3d226c5..1d9f469 100644 --- a/api/v1/db.py +++ b/api/v1/db.py @@ -1,4 +1,4 @@ -from peewee import SqliteDatabase, ForeignKeyField, CharField, Model, IntegerField +from peewee import SqliteDatabase, ForeignKeyField, CharField, Model, IntegerField, DateTimeField, BooleanField db = SqliteDatabase('datapackmanager.db') @@ -11,6 +11,8 @@ class BaseModel(Model): class User(BaseModel): name = CharField() id = IntegerField(primary_key=True) + email = CharField() + password_hash = CharField() class Category(BaseModel): @@ -18,18 +20,42 @@ class Category(BaseModel): id = IntegerField(primary_key=True) +class Tag(BaseModel): + name = CharField(primary_key=True) + + class DataPack(BaseModel): id = IntegerField(primary_key=True) name = CharField() description = CharField(max_length=10000) category = ForeignKeyField(Category) author = ForeignKeyField(User) + likes = IntegerField() + dislikes = IntegerField() + downloads = IntegerField() + views = IntegerField() + + +class TagRelation(BaseModel): + tags = ForeignKeyField(Tag) + packs = ForeignKeyField(DataPack) + + +class Comment(BaseModel): + id = IntegerField(primary_key=True) + datapack = ForeignKeyField(DataPack) + user = ForeignKeyField(User) + mesage = CharField(max_length=2000) + creation = DateTimeField() class Version(BaseModel): + id = IntegerField(primary_key=True) name = CharField() datapack = ForeignKeyField(DataPack) + prerelease = BooleanField() + releaedate = DateTimeField() -db.create_tables([DataPack, Category, Version, User]) -__all__ = ('DataPack', 'Category', 'Version', 'db') +db.create_tables([DataPack, Category, Version, User, Comment, TagRelation, Tag]) +__all__ = ['DataPack', 'Category', 'Version', 'User', 'Comment', 'TagRelation', 'Tag'] |