From 4d01a17002878c416e143cce8f6d42a64921e3f2 Mon Sep 17 00:00:00 2001 From: fakz9 Date: Sun, 28 Apr 2024 06:42:04 +0300 Subject: [PATCH] v0.1 --- models/deal.py | 2 +- models/secondary.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/models/deal.py b/models/deal.py index be038b3..d30283c 100644 --- a/models/deal.py +++ b/models/deal.py @@ -25,7 +25,7 @@ class Deal(BaseModel): created_at = Column(DateTime, 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') status_history = relationship('DealStatusHistory', back_populates='deal', cascade="all, delete-orphan") diff --git a/models/secondary.py b/models/secondary.py index 684855d..fd1ced3 100644 --- a/models/secondary.py +++ b/models/secondary.py @@ -9,8 +9,7 @@ class DealService(BaseModel): deal_id = Column(Integer, ForeignKey('deals.id'), nullable=False, comment='ID Сделки', - primary_key=True, - cascade='all, delete-orphan') + primary_key=True) deal = relationship('Deal', back_populates='services') service_id = Column(Integer, ForeignKey('services.id'), nullable=False, comment='ID Услуги', primary_key=True) @@ -25,9 +24,7 @@ class DealProduct(BaseModel): ForeignKey('deals.id'), nullable=False, comment='ID Сделки', - primary_key=True, - cascade='all, delete-orphan' - ) + primary_key=True) deal = relationship('Deal', back_populates='products') product_id = Column(Integer, ForeignKey('products.id'), nullable=False, comment='ID Продукта', primary_key=True)