diff --git a/app/models/family.rb b/app/models/family.rb index 6c1bc0c7b20..1871b400063 100644 --- a/app/models/family.rb +++ b/app/models/family.rb @@ -111,6 +111,7 @@ class Family index({"irs_groups.hbx_assigned_id" => 1}) index({"special_enrollment_periods._id" => 1}) + index({ "special_enrollment_periods.start_on" => 1, "special_enrollment_periods.end_on" => 1 }) index({"family_members.person_id" => 1, hbx_assigned_id: 1}) diff --git a/spec/models/family_spec.rb b/spec/models/family_spec.rb index 33007da8988..c0a288bca17 100644 --- a/spec/models/family_spec.rb +++ b/spec/models/family_spec.rb @@ -2296,4 +2296,11 @@ Family.remove_indexes Family.create_indexes end -end \ No newline at end of file + + it 'has the correct index on special_enrollment_periods fields' do + indexes = Family.index_specifications + expected_index = {:"special_enrollment_periods.start_on" => 1, :"special_enrollment_periods.end_on" => 1} + + expect(indexes.map(&:key)).to include(expected_index) + end +end