This commit is contained in:
2024-04-28 06:42:04 +03:00
parent ca0d424727
commit 4d01a17002
2 changed files with 3 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ class Deal(BaseModel):
created_at = Column(DateTime, nullable=False, comment='Дата создания') created_at = Column(DateTime, nullable=False, comment='Дата создания')
current_status = Column(Integer, nullable=False, comment='Текущий статус') current_status = Column(Integer, nullable=False, comment='Текущий статус')
client_id = Column(Integer, ForeignKey('clients.id'), nullable=False, comment='ID клиента', cascade='all, delete-orphan') client_id = Column(Integer, ForeignKey('clients.id', ondelete='CASCADE'), nullable=False, comment='ID клиента')
client = relationship('Client', backref='deals') client = relationship('Client', backref='deals')
status_history = relationship('DealStatusHistory', back_populates='deal', cascade="all, delete-orphan") status_history = relationship('DealStatusHistory', back_populates='deal', cascade="all, delete-orphan")

View File

@@ -9,8 +9,7 @@ class DealService(BaseModel):
deal_id = Column(Integer, ForeignKey('deals.id'), deal_id = Column(Integer, ForeignKey('deals.id'),
nullable=False, nullable=False,
comment='ID Сделки', comment='ID Сделки',
primary_key=True, primary_key=True)
cascade='all, delete-orphan')
deal = relationship('Deal', back_populates='services') deal = relationship('Deal', back_populates='services')
service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True) service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True)
@@ -25,9 +24,7 @@ class DealProduct(BaseModel):
ForeignKey('deals.id'), ForeignKey('deals.id'),
nullable=False, nullable=False,
comment='ID Сделки', comment='ID Сделки',
primary_key=True, primary_key=True)
cascade='all, delete-orphan'
)
deal = relationship('Deal', back_populates='products') deal = relationship('Deal', back_populates='products')
product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True) product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True)