###### tags: `Product` DevOps` # Orphaned data after entity removal Removing an entity, should remove all autogenerated sub-data and additional data created to it. The cases when Hub has a Challenge - deletion is not possible, as for Challenge having an opportunity. In order to identify remaining orphaned data after removeing a main entity the folowing entity modifications are performed and the following results are observed: ### Process of gathering orphaned data - Remove Alkemio database - Create Alkemio database - Run all migrations - Start server service - Run an empty test to generate users with credentials, that are normally executes as part of each test - Get snapshot of all tables: `SELECT count(id) FROM alkemio.table_name` - Run entity specific events - Get snapshot of all tables: `SELECT count(id) FROM alkemio.table_name` - Delete the entity under test - Compare the difference of the leftover data after removing the main entity ### Organization entity 1. Get Alkemio database snapshot 2. Create Organization 3. Events on Organization 1. Verify organization 2. Change organization preference 3. Assign user as organization member 4. Assign organization as hub community member and lead 5. Assign organization owner 6. Assign organization admin 7. Assign another organization owner and remove it 4. Delete Origanization 5. Get Alkemio database snapshot 6. Results from data comparison ``` authorization_policy 214 credential 16 lifecycle 3 ``` ### Hub entity 1. Get Alkemio database snapshot 2. Create Hub 3. Events on Hub 1. Change hub preference 2. Send hub community update 3. Create callout 4. Create canvas on callout 5. Create card on callout and comment to it 6. Create comment on callout 7. Create hub lifecycle template 8. Update hu visibility 9. User application to hub community 10. Assign user as member and lead 11. Assign organization as hub community member and lead 4. Delete Hub 5. Get Alkemio database snapshot 6. Results from data comparison ``` activity 5 aspect 1 aspect_template 11 authorization_policy 260 callout 9 canvas 1 canvas_checkout 1 card_profile 1 collaboration 2 comments 5 credential 16 lifecycle 5 tagset 12 template_info 10 visual 31 ``` ### Hub entity 1. Get Alkemio database snapshot 2. Create Challenge 3. Events on Challenge 1. Change challenge preference 2. Send challenge community update 3. Create callout 4. Create canvas on callout 5. Create card on callout and comment to it 6. Create comment on callout 7. Create challenge lifecycle template 8. Update challenge lifecycle event 9. User application to challenge community 10. Assign user as member and lead 11. Assign organization as challenge community member and lead 4. Delete Challenge 5. Get Alkemio database snapshot 6. Results from data comparison ``` activity 10 aspect 1 aspect_template 13 authorization_policy 276 callout 13 canvas 1 canvas_checkout 1 card_profile 1 collaboration 3 comments 7 credential 18 lifecycle 4 tagset 13 template_info 11 visual 31 ``` ### Hub entity 1. Get Alkemio database snapshot 2. Create Opportunity 3. Events on Opportunity 1. Change opportunity preference 2. Send opportunity community update 3. Create callout 4. Create canvas on callout 5. Create card on callout and comment to it 6. Create comment on callout 7. Create opportunity lifecycle template 8. Update opportunity lifecycle event 9. Assign user as member and lead 10. Assign organization as opportunity community member and lead 4. Delete Opportunity 5. Get Alkemio database snapshot 6. Results from data comparison ``` activity 10 aspect 1 aspect_template 13 authorization_policy 276 callout 13 canvas 1 canvas_checkout 1 card_profile 1 collaboration 3 comments 7 credential 18 lifecycle 4 tagset 13 template_info 11 visual 31 ``` ### User entity 1. Get Alkemio database snapshot after Organization, Hub, Challenge and Opportunity are created 2. Register user 3. Events on Organization 1. Change user preference 2. Assign organization as hub community member and lead to Hub 3. Assign organization as hub community member and lead to Challenge 4. Assign organization as hub community member and lead to Opportunity 5. Assign organization member 6. Assign organization owner 7. Assign organization admin 8. Remove user as organization owner 4. Delete User 5. Get Alkemio database snapshot 6. Results from data comparison ``` authorization_policy 338 ```