registration
This commit is contained in:
21
api/registration/models.py
Normal file
21
api/registration/models.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from sqlalchemy import String
|
||||
|
||||
from api.database import (Model, SurrogatePK, db,
|
||||
Column, relationship)
|
||||
|
||||
registration_target_assoc = db.Table(
|
||||
"registration_target",
|
||||
db.Column("registration", db.Integer(), db.ForeignKey("target.id")),
|
||||
db.Column("target", db.Integer(), db.ForeignKey("registration.id"))
|
||||
)
|
||||
|
||||
|
||||
class Registration(SurrogatePK, Model):
|
||||
__tablename__ = "registration"
|
||||
name = Column(String(255), unique=True, nullable=False)
|
||||
routing_key = Column(String(255), nullable=False)
|
||||
targets = relationship(
|
||||
"Target", secondary=registration_target_assoc, backref=db.backref("registrations"))
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(Registration, self).__init__(**kwargs)
|
||||
Reference in New Issue
Block a user