-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
30 lines (22 loc) · 877 Bytes
/
models.py
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
from sqlalchemy import Column, Integer, String, ForeignKey, Table, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from database import Base
class Transaction(Base):
__tablename__ = "transactions"
id = Column(String, primary_key=True)
created_at = Column(String)
updated_at = Column(String)
amount = Column(Float)
type = Column(String)
customer_id = Column(String)
merchant_id = Column(String, ForeignKey("merchants.id"))
order_id = Column(String)
merchant = relationship("Merchant", back_populates="transactions")
class Merchant(Base):
__tablename__ = "merchants"
id = Column(String, primary_key=True)
created_at = Column(String)
updated_at = Column(String)
name = Column(String)
transactions = relationship("Transaction", back_populates="merchant")