Skip to content

Commit

Permalink
Edit EP Claim Labels | Add End Product Update model (#15383)
Browse files Browse the repository at this point in the history
Connects  #15330

### Description
This pr adds a new End Product Update table and model

### Acceptance Criteria
- [ ] DB migration to add EndProductUpdate
  - [ ] Timestamps
  - [ ] User ID
  - [ ] EndProductEstablishment ID
  - [ ] Original code
  - [ ] New code
  - [ ] Original decision review ID
  - [ ] Status (success/error)
  - [ ] Error
  - [ ] IDs of active request issues on the end product establishment

### Database Changes
*Only for Schema Changes*

* [x] Timestamps (created_at, updated_at) for new tables
* [x] Column comments updated
* [x] Have your migration classes inherit from `Caseflow::Migration`, especially when adding indexes (use `add_safe_index`)
* [x] Verify that `migrate:rollback` works as desired ([`change` supported functions](https://edgeguides.rubyonrails.org/active_record_migrations.html#using-the-change-method))
* [ ] Query profiling performed (eyeball Rails log, check bullet and fasterer output)
* [x] Appropriate indexes added (especially for foreign keys, polymorphic columns, unique constraints, and Rails scopes)
* [x] DB schema docs updated with `make docs` (after running `make migrate`)
* [x] #appeals-schema notified with summary and link to this PR
  • Loading branch information
Sjones352 committed Oct 8, 2020
1 parent a9a2e30 commit b35e926
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/end_product_establishment.rb
Expand Up @@ -14,6 +14,7 @@ class EndProductEstablishment < CaseflowRecord
has_many :request_issues
has_many :end_product_code_updates
has_many :effectuations, class_name: "BoardGrantEffectuation"
has_many :end_product_updates

# allow @veteran to be assigned to save upstream calls
attr_writer :veteran
Expand Down
8 changes: 8 additions & 0 deletions app/models/end_product_update.rb
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# This is for updating the claim label for end products established from Caseflow

class EndProductUpdate < CaseflowRecord
belongs_to :end_product_establishment
belongs_to :original_decision_review, polymorphic: true
end
22 changes: 22 additions & 0 deletions db/migrate/20201005190456_create_end_product_update.rb
@@ -0,0 +1,22 @@
class CreateEndProductUpdate < Caseflow::Migration
disable_ddl_transaction!

def change
create_table :end_product_updates, comment: "Updates the claim label for end products established from Caseflow" do |t|
t.string :status, comment: "Status after an attempt to update the end product; expected values: 'success', 'error', ..."
t.string :error, comment: "The error message captured from BGS if the end product update failed."
t.string :original_code, comment: "The original end product code before the update was submitted."
t.string :new_code, comment: "The new end product code the user wants to update to."
t.bigint :active_request_issue_ids, null: false, array: true, default: [], comment: "A list of active request issue IDs when a user has finished editing a decision review. Used to keep track of which request issues may have been impacted by the update."

t.timestamps null: false
t.references :user, null: false, foreign_key: true, comment: "The ID of the user who makes an end product update."
t.references :end_product_establishment, null: false, foreign_key: true, comment: "The end product establishment id used to track the end product being updated."
t.references :original_decision_review, null: true, polymorphic: true, index: false, comment: "The original decision review that this end product update belongs to; has a non-nil value only if a new decision_review was created."
end

add_index :end_product_updates, [:original_decision_review_type, :original_decision_review_id], algorithm: :concurrently, name: "index_epupdates_on_decision_review_type_and_decision_review_id"

change_column_comment :end_product_updates, :original_decision_review_type, "The original decision review type that this end product update belongs to"
end
end
21 changes: 20 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_09_29_170305) do
ActiveRecord::Schema.define(version: 2020_10_05_190456) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -583,6 +583,23 @@
t.index ["veteran_file_number"], name: "index_end_product_establishments_on_veteran_file_number"
end

create_table "end_product_updates", comment: "Updates the claim label for end products established from Caseflow", force: :cascade do |t|
t.bigint "active_request_issue_ids", default: [], null: false, comment: "A list of active request issue IDs when a user has finished editing a decision review. Used to keep track of which request issues may have been impacted by the update.", array: true
t.datetime "created_at", null: false
t.bigint "end_product_establishment_id", null: false, comment: "The end product establishment id used to track the end product being updated."
t.string "error", comment: "The error message captured from BGS if the end product update failed."
t.string "new_code", comment: "The new end product code the user wants to update to."
t.string "original_code", comment: "The original end product code before the update was submitted."
t.bigint "original_decision_review_id", comment: "The original decision review that this end product update belongs to; has a non-nil value only if a new decision_review was created."
t.string "original_decision_review_type", comment: "The original decision review type that this end product update belongs to"
t.string "status", comment: "Status after an attempt to update the end product; expected values: 'success', 'error', ..."
t.datetime "updated_at", null: false
t.bigint "user_id", null: false, comment: "The ID of the user who makes an end product update."
t.index ["end_product_establishment_id"], name: "index_end_product_updates_on_end_product_establishment_id"
t.index ["original_decision_review_type", "original_decision_review_id"], name: "index_epupdates_on_decision_review_type_and_decision_review_id"
t.index ["user_id"], name: "index_end_product_updates_on_user_id"
end

create_table "form8s", id: :serial, force: :cascade do |t|
t.string "_initial_appellant_name"
t.string "_initial_appellant_relationship"
Expand Down Expand Up @@ -1552,6 +1569,8 @@
add_foreign_key "docket_changes", "tasks"
add_foreign_key "document_views", "users"
add_foreign_key "end_product_establishments", "users"
add_foreign_key "end_product_updates", "end_product_establishments"
add_foreign_key "end_product_updates", "users"
add_foreign_key "hearing_days", "users", column: "created_by_id"
add_foreign_key "hearing_days", "users", column: "updated_by_id"
add_foreign_key "hearing_views", "users"
Expand Down
10 changes: 10 additions & 0 deletions docs/schema/caseflow.csv
Expand Up @@ -409,6 +409,16 @@ end_product_code_updates,created_at,datetime ∗,x,,,,,
end_product_code_updates,end_product_establishment_id,integer (8) ∗ FK,x,,x,,x,
end_product_code_updates,id,integer (8) PK,x,x,,,,
end_product_code_updates,updated_at,datetime ∗,x,,,,x,
end_product_updates,,,,,,,, "Updates the claim label for end products established from Caseflow."
end_product_updates,user_id,integer,"The ID of the user who makes an end product update."
end_product_updates,end_product_establishment_id,bigint,"The end product establishment id used to track the end product being updated"
end_product_updates,original_decision_review_id,bigint,"The original ID of the decision review that this end product update belongs to; has a non-nil value only if a new decision_review was created."
end_product_updates,original_decision_review_type,string,"The original decision review type that this end product update belongs to"
end_product_updates,status,string,"Status after an attempt to update the end product; expected values: 'success', 'error', ..."
end_product_updates,error,string,"The error message captured from BGS if the end product update failed."
end_product_updates,original_code,string,"The original end product code before the update was submitted"
end_product_updates,new_code,string,"The new end product code the user wants to update to."
end_product_updates,active_request_issue_ids,integer,"A list of active request issue IDs when a user has finished editing a decision review. Used to keep track of which request issues may have been impacted by the update."
end_product_establishments,,,,,,,,"Represents end products that have been, or need to be established by Caseflow. Used to track the status of those end products as they are processed in VBMS and/or SHARE."
end_product_establishments,benefit_type_code,string,,,,,,"1 if the Veteran is alive, and 2 if the Veteran is deceased. Not to be confused with benefit_type, which is unrelated."
end_product_establishments,claim_date,date,,,,,,The claim_date for end product established.
Expand Down

0 comments on commit b35e926

Please sign in to comment.