diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 4ab6b5127a57638939253d1c08861598bfae791e..ba085aa570d28f80cdc2f7b7454e0f7a6085fd01 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -67,12 +67,18 @@ class Education::Program < ApplicationRecord has_many :teachers, class_name: 'Education::Program::Teacher', dependent: :destroy - has_many :people, + has_many :university_people_through_teachers, through: :teachers, - dependent: :destroy + source: :person has_many :roles, class_name: 'Education::Program::Role', dependent: :destroy + has_many :role_people, + through: :roles, + source: :person + has_many :university_people_through_roles, + through: :role_people, + source: :person has_many :website_categories, class_name: 'Communication::Website::Category', dependent: :destroy @@ -115,8 +121,11 @@ class Education::Program < ApplicationRecord end def git_dependencies_static - # TODO: Add Teacher & Role::Person - active_storage_blobs + [ + active_storage_blobs, + university_people_through_teachers, + university_people_through_roles + ].flatten.uniq.compact end def git_destroy_dependencies_static diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 481511e1b0f01776bc614e3b9de1996637e61446..558d22a9325e992297d866c43b35fca131e308be 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -43,7 +43,10 @@ class University::Person < ApplicationRecord has_many :education_program_teachers, class_name: 'Education::Program::Teacher', - foreign_key: :person_id, + dependent: :destroy + + has_many :education_program_role_people, + class_name: 'Education::Program::Role::Person', dependent: :destroy has_many :education_programs,