ARA-Trans / iAM

iAM - Infrastructure Asset Management
GNU Affero General Public License v3.0
4 stars 4 forks source link

vnext/680: Replace BUDGETNAME with BUDGET_CRITERIA_ID as the FK into BUDGET_CRITERIA table from YEARLYINVESTMENT table #835

Open ppator1 opened 4 years ago

ppator1 commented 4 years ago

-created sql script that will:

  1. remove all duplicate BUDGET_CRITERIA records
  2. add BUDGET_CRITERIA_ID column to YEARLYINVESTMENT
  3. set the BUDGET_CRITERIA_ID for YEARLYINVESTMENT records using a BUDGET_CRITERIA record that has a match for the YEARLYINVESTMENT SIMULATIONID & BUDGETNAME
  4. create new BUDGET_CRITERIA records for any YEARLYINVESTMENT records that did not have a matching BUDGET_CRITERIA record from step 3
  5. re-run step 3 with added condition that only YEARLYINVESTMENT records that didn't have a match from step 3 be updated
  6. remove BUDGETNAME column from YEARLYINVESTMENT
  7. set YEARLYINVESTMENT BUDGET_CRITERIA_ID to not nullable
  8. create foreign key on YEARLYINVESTMENT to BUDGET_CRITERIA using YEARLYINVESTMENT BUDGET_CRITERIA_ID -modified all API and code behind references to YEARLYINVESTMENT entity by removing the BUDGETNAME column and adding the new BUDGET_CRITERIA_ID column (all logic based on around the removed column has been updated to work with the new column)