summaryrefslogtreecommitdiff
path: root/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'api/v1')
-rw-r--r--api/v1/db.py32
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']