added missing foreign keys; removed unused tables

This commit is contained in:
Notisset 2017-10-01 18:04:47 +02:00
parent c89a4bc537
commit b55792e5e3
2 changed files with 6 additions and 23 deletions

View File

@ -109,6 +109,8 @@ class Entry(Base):
starts_at = Column(DateTime, nullable=False, default=datetime.now) starts_at = Column(DateTime, nullable=False, default=datetime.now)
ends_at = Column(DateTime) ends_at = Column(DateTime)
created_at = Column(DateTime, nullable=False, default=datetime.now) created_at = Column(DateTime, nullable=False, default=datetime.now)
event_uid = Column(Integer, ForeignKey('event.uid'),
nullable=False)
class Event(Base): class Event(Base):
@ -118,6 +120,8 @@ class Event(Base):
starts_at = Column(DateTime, nullable=False, default=datetime.now) starts_at = Column(DateTime, nullable=False, default=datetime.now)
ends_at = Column(DateTime) ends_at = Column(DateTime)
created_at = Column(DateTime, nullable=False, default=datetime.now) created_at = Column(DateTime, nullable=False, default=datetime.now)
group_uid = Column(Integer, ForeignKey('group.uid'),
nullable=False)
entries = relationship('Entry', lazy='joined') entries = relationship('Entry', lazy='joined')
@ -129,7 +133,7 @@ class Group(Base):
description = Column(String, nullable=False) description = Column(String, nullable=False)
created_at = Column(DateTime, nullable=False, default=datetime.now) created_at = Column(DateTime, nullable=False, default=datetime.now)
products = relationship('Event', lazy='joined') events = relationship('Event', lazy='joined')
class ProductCategory(Base): class ProductCategory(Base):
@ -154,25 +158,3 @@ class Product(Base):
created_at = Column(DateTime, nullable=False, default=datetime.now) created_at = Column(DateTime, nullable=False, default=datetime.now)
category = relationship('ProductCategory', lazy='joined') category = relationship('ProductCategory', lazy='joined')
class Transaction(Base):
__tablename__ = 'transactions'
uid = Column(Integer, primary_key=True)
event_uid = Column(Integer, ForeignKey('events.uid'), nullable=False)
created_at = Column(DateTime, nullable=False, default=datetime.now)
event = relationship('Event', lazy='joined')
orders = relationship('Order', lazy='joined')
class Order(Base):
__tablename__ = 'orders'
uid = Column(Integer, primary_key=True)
product_uid = Column(Integer, ForeignKey('products.uid'), nullable=False)
quantity = Column(Integer, nullable=False)
transaction_uid = Column(Integer, ForeignKey(
'transactions.uid'), nullable=False)
product = relationship('Product', lazy='joined')
transaction = relationship('Transaction', lazy='joined')

1
web.py
View File

@ -27,6 +27,7 @@ if __name__ == '__main__':
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
app = setup_app(loop, config) app = setup_app(loop, config)
app['db'] = db
web.run_app(app, web.run_app(app,
host=config.core.get('GENERAL', 'Address'), host=config.core.get('GENERAL', 'Address'),
port=config.core.getint('GENERAL', 'Port')) port=config.core.getint('GENERAL', 'Port'))