refactor: moving more models to mapped_column
This commit is contained in:
parent
ea020d6edd
commit
75b2c1adf0
9 changed files with 272 additions and 94 deletions
|
@ -2,9 +2,12 @@ import enum
|
|||
from datetime import datetime
|
||||
from typing import List
|
||||
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.brm.brn import BRN
|
||||
from app.extensions import db
|
||||
from app.models import AbstractConfiguration, AbstractResource
|
||||
from app.models.base import Pool
|
||||
|
||||
|
||||
class ProviderAllocation(enum.Enum):
|
||||
|
@ -13,15 +16,15 @@ class ProviderAllocation(enum.Enum):
|
|||
|
||||
|
||||
class BridgeConf(AbstractConfiguration):
|
||||
pool_id = db.Column(db.Integer, db.ForeignKey("pool.id"), nullable=False)
|
||||
method = db.Column(db.String(20), nullable=False)
|
||||
target_number = db.Column(db.Integer())
|
||||
max_number = db.Column(db.Integer())
|
||||
expiry_hours = db.Column(db.Integer())
|
||||
provider_allocation = db.Column(db.Enum(ProviderAllocation))
|
||||
pool_id: Mapped[int] = mapped_column(db.Integer, db.ForeignKey("pool.id"))
|
||||
method: Mapped[str]
|
||||
target_number: Mapped[int]
|
||||
max_number: Mapped[int]
|
||||
expiry_hours: Mapped[int]
|
||||
provider_allocation: Mapped[ProviderAllocation]
|
||||
|
||||
pool = db.relationship("Pool", back_populates="bridgeconfs")
|
||||
bridges = db.relationship("Bridge", back_populates="conf")
|
||||
pool: Mapped[Pool] = relationship("Pool", back_populates="bridgeconfs")
|
||||
bridges: Mapped[List["Bridge"]] = relationship("Bridge", back_populates="conf")
|
||||
|
||||
@property
|
||||
def brn(self) -> BRN:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue