Skip to content

Commit

Permalink
Clean up after data migration (#1690)
Browse files Browse the repository at this point in the history
  • Loading branch information
samnang authored Jan 8, 2025
1 parent ab53653 commit 8156700
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 104 deletions.
5 changes: 3 additions & 2 deletions app/workflows/handle_phone_call_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def create_or_find_contact!(platform_account_sid, msisdn)
Contact.find_or_create_by!(
account: account,
msisdn: PhonyRails.normalize_number(msisdn),
iso_country_code: ACCOUNT_COUNTRY_CODES.fetch(account.id, "KH")
)
) do |record|
record.iso_country_code = ACCOUNT_COUNTRY_CODES.fetch(account.id, "KH")
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeIsoCountryCodeNotNullOnBeneficiaries < ActiveRecord::Migration[8.0]
def change
change_column_null :contacts, :iso_country_code, false
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2025_01_07_072933) do
ActiveRecord::Schema[8.0].define(version: 2025_01_08_072200) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_catalog.plpgsql"
Expand Down Expand Up @@ -138,7 +138,7 @@
t.string "language_code"
t.string "gender"
t.date "date_of_birth"
t.citext "iso_country_code"
t.citext "iso_country_code", null: false
t.index ["account_id", "date_of_birth"], name: "index_contacts_on_account_id_and_date_of_birth"
t.index ["account_id", "gender"], name: "index_contacts_on_account_id_and_gender"
t.index ["account_id", "iso_country_code"], name: "index_contacts_on_account_id_and_iso_country_code"
Expand Down

This file was deleted.

5 changes: 3 additions & 2 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

factory :contact, aliases: [ :beneficiary ] do
account
iso_country_code { "SO" }
msisdn { generate(:somali_msisdn) }

trait :disabled do
Expand Down Expand Up @@ -219,7 +220,7 @@

factory :beneficiary_address do
beneficiary
iso_country_code { "KH" }
iso_region_code { "KH-1" }
iso_country_code { beneficiary.iso_country_code }
iso_region_code { "SO-AW" }
end
end

0 comments on commit 8156700

Please sign in to comment.