Skip to content

Commit 84d0d8e

Browse files
Remove uniqueness requirement for district nces id (#652)
## What's changed? - Removes uniqueness validation for `district_nces_id`
1 parent 8f39c7c commit 84d0d8e

5 files changed

Lines changed: 6 additions & 10 deletions

File tree

app/models/school.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class School < ApplicationRecord
2323
format: { with: /\A\d{5,6}\z/, allow_nil: true, message: I18n.t('validations.school.reference') },
2424
if: :united_kingdom?
2525
validates :district_nces_id,
26-
uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.district_nces_id_exists') },
2726
format: { with: /\A\d{7}\z/, allow_nil: true, message: I18n.t('validations.school.district_nces_id') },
2827
if: :united_states?
2928
validates :district_name, presence: true, if: :united_states?

config/locales/en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ en:
1818
reference: "must be 5-6 digits (e.g., 100000)"
1919
reference_urn_exists: "URN number already exists"
2020
district_nces_id: "must be 7 digits (e.g., 0100000)"
21-
district_nces_id_exists: "NCES ID already exists"
2221
school_roll_number: "must be numbers followed by letters (e.g., 01572D)"
2322
school_roll_number_exists: "School roll number already exists"
2423
invitation:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class RemoveUniqueIndexFromSchoolsDistrictNcesId < ActiveRecord::Migration[7.2]
2+
def change
3+
remove_index :schools, name: "index_schools_on_district_nces_id"
4+
end
5+
end

db/schema.rb

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/models/school_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@
241241
expect(duplicate_school).not_to be_valid
242242
end
243243

244-
it 'returns error if district_nces_id is not unique' do
245-
duplicate_school = build(:school, country_code: 'US', district_nces_id: '0100000')
246-
duplicate_school.valid?
247-
expect(duplicate_school.errors.details[:district_nces_id]).to include(hash_including(error: :taken))
248-
end
249-
250244
it 'accepts a valid district_nces_id format (7 digits)' do
251245
us_school.district_nces_id = '0100000'
252246
expect(us_school).to be_valid

0 commit comments

Comments
 (0)