diff --git a/app/models/conference.rb b/app/models/conference.rb index 2f70f75..02a7a0a 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -18,11 +18,11 @@ class Conference < ActiveRecord::Base has_many :conflict_counts, through: :events has_many :volunteer_teams has_many :volunteers - has_one :call_for_participation, dependent: :destroy + has_one :call_for_participation has_many :participants, -> { distinct }, class_name: 'User', through: :events has_many :participant_profiles, class_name: 'PersonalProfile' has_many :slots, through: :halls - has_many :feedbacks, as: :feedback_receiving, dependent: :destroy + has_many :feedbacks, as: :feedback_receiving has_many :editions, primary_key: :host_name, foreign_key: :host_name, class_name: 'Conference' has_many :events_of_all_editions, through: :editions, source: :events diff --git a/db/migrate/20190428101041_add_referential_integrity.rb b/db/migrate/20190428101041_add_referential_integrity.rb new file mode 100644 index 0000000..ef5f2e1 --- /dev/null +++ b/db/migrate/20190428101041_add_referential_integrity.rb @@ -0,0 +1,40 @@ +class AddReferentialIntegrity < ActiveRecord::Migration[5.2] + def change + remove_foreign_key :call_for_participations, :conferences + add_foreign_key :call_for_participations, :conferences, on_delete: :cascade + + add_foreign_key :conference_translations, :conferences, on_delete: :cascade + + add_foreign_key :conflict_counts, :events, column: :left_id, on_delete: :cascade + add_foreign_key :conflict_counts, :events, column: :right_id, on_delete: :cascade + + add_foreign_key :event_type_translations, :event_types, on_delete: :cascade + + remove_foreign_key :event_types, :conferences + add_foreign_key :event_types, :conferences, on_delete: :cascade + + add_foreign_key :hall_translations, :halls, on_delete: :cascade + + add_foreign_key :halls, :conferences, on_delete: :cascade + + add_foreign_key :personal_profiles, :users, on_delete: :cascade + add_foreign_key :personal_profiles, :conferences + + add_foreign_key :propositions, :users, column: :proposer_id + + add_foreign_key :slots, :halls, on_delete: :cascade + add_foreign_key :slots, :events, on_delete: :nullify + + add_foreign_key :track_translations, :tracks, on_delete: :cascade + + add_foreign_key :tracks, :conferences, on_delete: :cascade + + add_foreign_key :volunteer_team_translations, :volunteer_teams, on_delete: :cascade + + remove_foreign_key :volunteer_teams, :conferences + add_foreign_key :volunteer_teams, :conferences, on_delete: :cascade + + add_foreign_key :volunteer_teams_volunteers, :volunteers, on_delete: :cascade + add_foreign_key :volunteer_teams_volunteers, :volunteer_teams, on_delete: :cascade + end +end