Browse Source

added missing foreign keys; removed unused tables

master
Notisset 5 years ago
parent
commit
b55792e5e3
  1. 28
      autogestionale/database.py
  2. 1
      web.py

28
autogestionale/database.py

@ -109,6 +109,8 @@ class Entry(Base):
starts_at = Column(DateTime, nullable=False, default=datetime.now)
ends_at = Column(DateTime)
created_at = Column(DateTime, nullable=False, default=datetime.now)
event_uid = Column(Integer, ForeignKey('event.uid'),
nullable=False)
class Event(Base):
@ -118,6 +120,8 @@ class Event(Base):
starts_at = Column(DateTime, nullable=False, default=datetime.now)
ends_at = Column(DateTime)
created_at = Column(DateTime, nullable=False, default=datetime.now)
group_uid = Column(Integer, ForeignKey('group.uid'),
nullable=False)
entries = relationship('Entry', lazy='joined')
@ -129,7 +133,7 @@ class Group(Base):
description = Column(String, nullable=False)
created_at = Column(DateTime, nullable=False, default=datetime.now)
products = relationship('Event', lazy='joined')
events = relationship('Event', lazy='joined')
class ProductCategory(Base):
@ -154,25 +158,3 @@ class Product(Base):
created_at = Column(DateTime, nullable=False, default=datetime.now)
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

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

Loading…
Cancel
Save