summaryrefslogtreecommitdiff
path: root/api/v1/db.py
blob: 3d226c5c9359be26907a4b250e56542581679ceb (plain)
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
from peewee import SqliteDatabase, ForeignKeyField, CharField, Model, IntegerField

db = SqliteDatabase('datapackmanager.db')


class BaseModel(Model):
    class Meta:
        database = db


class User(BaseModel):
    name = CharField()
    id = IntegerField(primary_key=True)


class Category(BaseModel):
    name = CharField()
    id = IntegerField(primary_key=True)


class DataPack(BaseModel):
    id = IntegerField(primary_key=True)
    name = CharField()
    description = CharField(max_length=10000)
    category = ForeignKeyField(Category)
    author = ForeignKeyField(User)


class Version(BaseModel):
    name = CharField()
    datapack = ForeignKeyField(DataPack)


db.create_tables([DataPack, Category, Version, User])
__all__ = ('DataPack', 'Category', 'Version', 'db')