Skip to content

Commit 62d44f8

Browse files
authored
Merge pull request #34 from SynergyX-AI-Pattern/refactor/#33_update_pattern_constraints_relations
Refactor/#33 update pattern constraints relations
2 parents 265e17f + 5fb9ea1 commit 62d44f8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

app/models/pattern_apply.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PatternApply(BaseTimeModel):
1111

1212
id = Column(BigInteger, primary_key=True, autoincrement=True)
1313

14-
pattern_id = Column(BigInteger, ForeignKey("pattern.id"), nullable=False)
14+
pattern_id = Column(BigInteger, ForeignKey("pattern.id", ondelete="CASCADE"), nullable=False)
1515

1616
stock_id = Column(BigInteger, ForeignKey("stock.id"), nullable=False)
1717

@@ -23,4 +23,4 @@ class PatternApply(BaseTimeModel):
2323
# 관계 설정
2424
pattern = relationship("Pattern", back_populates="pattern_applies")
2525
stock = relationship("Stock", back_populates="pattern_applies")
26-
detection_results = relationship("PatternDetectionLog", back_populates="pattern_apply")
26+
detection_results = relationship("PatternDetectionLog", back_populates="pattern_apply", cascade="all, delete-orphan", passive_deletes=True)

app/models/pattern_detection_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PatternDetectionLog(BaseTimeModel):
88

99
id = Column(BigInteger, primary_key=True, autoincrement=True)
1010

11-
pattern_apply_id = Column(BigInteger, ForeignKey("pattern_apply.id"), nullable=False)
11+
pattern_apply_id = Column(BigInteger, ForeignKey("pattern_apply.id", ondelete="CASCADE"), nullable=False)
1212

1313
detected_at = Column(DateTime, nullable=False)
1414

0 commit comments

Comments
 (0)