From 210edd234721a8d57b6a981889114b3ed55f1a78 Mon Sep 17 00:00:00 2001 From: Oren Mittman Date: Mon, 23 Dec 2024 08:12:59 -0500 Subject: [PATCH] [ART] POA request accredited entites migration --- db/schema.rb | 8 ++++++- ...quest_references_to_accredited_entities.rb | 21 +++++++++++++++++++ ...uest_foreign_key_to_accredited_entities.rb | 6 ++++++ ...30702_validate_poa_request_foreign_keys.rb | 6 ++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 modules/accredited_representative_portal/db/migrate/20241223125305_add_poa_request_references_to_accredited_entities.rb create mode 100644 modules/accredited_representative_portal/db/migrate/20241223130159_add_poa_request_foreign_key_to_accredited_entities.rb create mode 100644 modules/accredited_representative_portal/db/migrate/20241223130702_validate_poa_request_foreign_keys.rb diff --git a/db/schema.rb b/db/schema.rb index 8e9ea3df4a4..d8d390478aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_23_094500) do +ActiveRecord::Schema[7.2].define(version: 2024_12_23_130702) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "fuzzystrmatch" @@ -307,6 +307,10 @@ t.uuid "claimant_id", null: false t.datetime "created_at", null: false t.string "claimant_type", null: false + t.uuid "accredited_individual_id", null: false + t.uuid "accredited_organization_id" + t.index ["accredited_individual_id"], name: "idx_on_accredited_individual_id_a0a1fab1e0" + t.index ["accredited_organization_id"], name: "idx_on_accredited_organization_id_03bee0c771" t.index ["claimant_id"], name: "index_ar_power_of_attorney_requests_on_claimant_id" end @@ -1762,6 +1766,8 @@ add_foreign_key "ar_power_of_attorney_forms", "ar_power_of_attorney_requests", column: "power_of_attorney_request_id" add_foreign_key "ar_power_of_attorney_request_decisions", "user_accounts", column: "creator_id" add_foreign_key "ar_power_of_attorney_request_resolutions", "ar_power_of_attorney_requests", column: "power_of_attorney_request_id" + add_foreign_key "ar_power_of_attorney_requests", "accredited_individuals" + add_foreign_key "ar_power_of_attorney_requests", "accredited_organizations" add_foreign_key "ar_power_of_attorney_requests", "user_accounts", column: "claimant_id" add_foreign_key "async_transactions", "user_accounts" add_foreign_key "claim_va_notifications", "saved_claims" diff --git a/modules/accredited_representative_portal/db/migrate/20241223125305_add_poa_request_references_to_accredited_entities.rb b/modules/accredited_representative_portal/db/migrate/20241223125305_add_poa_request_references_to_accredited_entities.rb new file mode 100644 index 00000000000..b936b9dae49 --- /dev/null +++ b/modules/accredited_representative_portal/db/migrate/20241223125305_add_poa_request_references_to_accredited_entities.rb @@ -0,0 +1,21 @@ +class AddPoaRequestReferencesToAccreditedEntities < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + + def change + add_reference( + :ar_power_of_attorney_requests, + :accredited_individual, + type: :uuid, + null: false, + index: { algorithm: :concurrently } + ) + + add_reference( + :ar_power_of_attorney_requests, + :accredited_organization, + type: :uuid, + null: true, + index: { algorithm: :concurrently } + ) + end +end diff --git a/modules/accredited_representative_portal/db/migrate/20241223130159_add_poa_request_foreign_key_to_accredited_entities.rb b/modules/accredited_representative_portal/db/migrate/20241223130159_add_poa_request_foreign_key_to_accredited_entities.rb new file mode 100644 index 00000000000..a93b649ce17 --- /dev/null +++ b/modules/accredited_representative_portal/db/migrate/20241223130159_add_poa_request_foreign_key_to_accredited_entities.rb @@ -0,0 +1,6 @@ +class AddPoaRequestForeignKeyToAccreditedEntities < ActiveRecord::Migration[7.1] + def change + add_foreign_key :ar_power_of_attorney_requests, :accredited_individuals, validate: false + add_foreign_key :ar_power_of_attorney_requests, :accredited_organizations, validate: false + end +end diff --git a/modules/accredited_representative_portal/db/migrate/20241223130702_validate_poa_request_foreign_keys.rb b/modules/accredited_representative_portal/db/migrate/20241223130702_validate_poa_request_foreign_keys.rb new file mode 100644 index 00000000000..15a2e2fd7be --- /dev/null +++ b/modules/accredited_representative_portal/db/migrate/20241223130702_validate_poa_request_foreign_keys.rb @@ -0,0 +1,6 @@ +class ValidatePoaRequestForeignKeys < ActiveRecord::Migration[7.1] + def change + validate_foreign_key :ar_power_of_attorney_requests, :accredited_individuals + validate_foreign_key :ar_power_of_attorney_requests, :accredited_organizations + end +end