GutoVeronezi opened a new pull request #4699:
URL: https://github.com/apache/cloudstack/pull/4699


   ### Description
   `ACS` has some APIs to manage `guest_os` and `guest_os_hypervisor` mapping 
entries; however, it is impracticable to use it due to the way we have been 
working.
   
   Most times we add data to these tables via `SQLs` with a hardcoded `id`. 
(See 
[schema-41200to41300.sql](https://github.com/apache/cloudstack/blob/0f3f2a09370a18301db28ec3d28efe746b6437c9/engine/schema/src/main/resources/META-INF/db/schema-41200to41300.sql)).
 Therefore, if an operator adds a new row to `guest_os` via the API, when 
he/she updates the version to any that insert a new row to `guest_os`, it might 
break the update due to duplicated id.
   
   An `INSERT IGNORE` would avoid the breaking, but it would not insert the new 
row (if it contains different data/information/configuration); therefore, it 
does not seem like a good solution. Although it may not happen often, it could 
generate duplicated data (like display_name...). 
   
   This PR intends to add new data in `guest_os` and to suggest a new way to 
insert `guest_os` data via `SQL`, verifying if it already exists on the table 
(with `insert... select ... where not exists`). 
   
   Obs: we used a temporary table to avoid repeating the code.
   
   ### Types of changes
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   - [ ] Major
   - [x] Minor
   
   ### How Has This Been Tested?
   It has been tested locally on a test lab.
   1. I generated the packages and updated my lab;


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to