import peewee as pw from peewee import Model, DatabaseProxy db_proxy = DatabaseProxy() class BaseModel(Model): id = pw.PrimaryKeyField() class Meta: database = db_proxy class Role(BaseModel): name = pw.TextField() class Meta: db_table = 'roles' class User(BaseModel): name = pw.TextField() role = pw.ForeignKeyField(Role.id) class Meta: db_table = 'users' class Location(BaseModel): name = pw.TextField() class Meta: db_table = 'locations' class Dashboard(BaseModel): name = pw.TextField() location = pw.ForeignKeyField(Location.id) class Meta: db_table = 'dashboards' class Event(BaseModel): name = pw.TextField() dashboard = pw.ForeignKeyField(Dashboard.id) active = pw.BooleanField() location = pw.ForeignKeyField(Location.id) start_time = pw.DateTimeField() end_time = pw.DateTimeField() duration = pw.DateTimeField() class Meta: db_table = 'events' class Reminder(BaseModel): name = pw.TextField() event = pw.ForeignKeyField(Event.id) class Meta: db_table = 'reminders' class Task(BaseModel): name = pw.TextField() event = pw.ForeignKeyField(Event.id) interval = pw.IntegerField() class Meta: db_table = 'tasks'