ilyass yani commited on
Commit
4b9b293
·
1 Parent(s): 9614c9c

Batch-2: CosineScorer, delete/put candidats, BOM extraction, ranking, cascade delete, _can_access_profile, foreign_keys

Browse files
Files changed (1) hide show
  1. app/models/models.py +8 -5
app/models/models.py CHANGED
@@ -79,11 +79,14 @@ class Candidate(Base):
79
 
80
  # Relationships
81
  user = relationship("User", back_populates="candidate", foreign_keys=[user_id])
82
- candidate_skills = relationship("CandidateSkill", back_populates="candidate")
83
- experiences = relationship("Experience", back_populates="candidate")
84
- educations = relationship("Education", back_populates="candidate")
85
- match_results = relationship("MatchResult", back_populates="candidate")
86
- favorites = relationship("Favorite", back_populates="candidate")
 
 
 
87
 
88
 
89
  class Skill(Base):
 
79
 
80
  # Relationships
81
  user = relationship("User", back_populates="candidate", foreign_keys=[user_id])
82
+ # cascade="all, delete-orphan" ensures child rows are deleted (not nullified) when
83
+ # the candidate is deleted. Without this, SQLAlchemy tries SET candidate_id=NULL
84
+ # which violates the NOT NULL constraint on every child table.
85
+ candidate_skills = relationship("CandidateSkill", back_populates="candidate", cascade="all, delete-orphan")
86
+ experiences = relationship("Experience", back_populates="candidate", cascade="all, delete-orphan")
87
+ educations = relationship("Education", back_populates="candidate", cascade="all, delete-orphan")
88
+ match_results = relationship("MatchResult", back_populates="candidate", cascade="all, delete-orphan")
89
+ favorites = relationship("Favorite", back_populates="candidate", cascade="all, delete-orphan")
90
 
91
 
92
  class Skill(Base):