added target entity

This commit is contained in:
Gardient
2021-09-21 21:23:14 +03:00
parent 8e67a58630
commit aeb8916744
7 changed files with 128 additions and 2 deletions

12
api/target/models.py Normal file
View File

@@ -0,0 +1,12 @@
from api.database import (Model, SurrogatePK, db,
Column, reference_col, relationship)
from sqlalchemy import String
from api.target_exchange.models import TargetExchange
class Target(SurrogatePK, Model):
__tablename__ = "target"
name = Column(String(255), unique=True, nullable=False)
routing_key = Column(String(255), nullable=False)
target_exchange_id = reference_col(TargetExchange.__tablename__, nullable=False)
exchange = relationship(TargetExchange.__name__, backref=db.backref('targets'))