Add an ORM layer
- use SQLAlchemy (and PostgreSQL) to model the ORM layer
- add the following models:
+ Address => modelling all kinds of addresses
+ City => model the three target cities
+ Courier => model the UDP's couriers
+ Customer => model the UDP's customers
+ Order => model the orders received by the UDP
+ Restaurant => model the restaurants active on the UDP
- so far, the emphasis lies on expression the Foreign Key
and Check Constraints that are used to validate the assumptions
inherent to the cleanded data
- provide database-independent unit tests with 100% coverage
- provide additional integration tests ("e2e") that commit data to
a PostgreSQL instance to validate that the constraints work
- adapt linting rules a bit
This commit is contained in:
parent
d219fa816d
commit
fdcc93a1ea
24 changed files with 2119 additions and 4 deletions
26
src/urban_meal_delivery/db/customers.py
Normal file
26
src/urban_meal_delivery/db/customers.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Provide the ORM's Customer model."""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from urban_meal_delivery.db import meta
|
||||
|
||||
|
||||
class Customer(meta.Base):
|
||||
"""A Customer of the UDP."""
|
||||
|
||||
# pylint:disable=too-few-public-methods
|
||||
|
||||
__tablename__ = 'customers'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Non-literal text representation."""
|
||||
return '<{cls}(#{customer_id})>'.format(
|
||||
cls=self.__class__.__name__, customer_id=self.id,
|
||||
)
|
||||
|
||||
# Relationships
|
||||
orders = orm.relationship('Order', back_populates='customer')
|
||||
Loading…
Add table
Add a link
Reference in a new issue