Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@GrahamS-Quartech
Copy link
Contributor

🎯 Summary

PIMS-1703

  • Added migrations for soft deleting parcels, buildings, projects, and all their related entities.
  • These migrations add deleted by id and deleted on columns. TypeORM automatically excludes rows with the delete on column as non-null, this is the soft deleted aspect.
  • Soft deletion is incorporated into adding/removing properties/agencies during project updates. Note that because agency responses use composite keys, the previously "deleted" row will simply be restored instead of a new row being created.
  • Frontend now correctly calls the delete endpoints using the useDataSubmitter hook. Delete dialog should show loading spinner and cause a snackbar popup on completion.
  • Deletion is done in transaction blocks so that a rollback will happen if a related entity does not delete correctly.
  • If you try to delete a property that is linked to a project, it just returns a 403 right now (perhaps there's a better code for this?)

🔰 Checklist

  • I have read and agree with the following checklist and am following the guidelines in our Code of Conduct document.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation where required.
  • I have tested my changes to the best of my ability.
  • My changes generate no new warnings.

…peration in a transaction block and made sure that migration correctly includes FK reference to user table
…handle project soft deletes. Updating agency responses and properties can also trigger soft deletes. UI makes delete call now.
@github-actions
Copy link

🚀 Deployment Information

The Express API Image has been built with the tag: 2400. Please make sure to utilize this specific tag when promoting these changes to the TEST and PROD environments during the API deployment. For more updates please monitor Image Tags Page on Wiki.

@qlty-cloud-legacy
Copy link

qlty-cloud-legacy bot commented May 22, 2024

Code Climate has analyzed commit 370a193 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 83.8% (50% is the threshold).

This pull request will bring the total coverage in the repository to 94.4%.

View more on Code Climate.

@github-actions
Copy link

🚀 Deployment Information

The React APP Image has been built with the tag: 2400. Please make sure to utilize this specific tag when promoting these changes to the TEST and PROD environments during the APP deployment. For more updates please monitor Image Tags Page on Wiki.

Copy link
Collaborator

@dbarkowsky dbarkowsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual tests of deletions seems to be working as expected, removing them from user's view.
Unfortunate we have to use update functions for this to save the user id, but I think that's the only way unless we write a custom function for the soft delete entity, which might not work because our IDs aren't consistent.

@GrahamS-Quartech
Copy link
Contributor Author

GrahamS-Quartech commented May 22, 2024

Manual tests of deletions seems to be working as expected, removing them from user's view. Unfortunate we have to use update functions for this to save the user id, but I think that's the only way unless we write a custom function for the soft delete entity, which might not work because our IDs aren't consistent.

Yeah, softDelete function really seems to do nothing more than set the delete date field with no additional options like setting an additional field. I think using update make the intention less clear than calling softDelete but considering softDelete itself still results in an SQL UPDATE query, I think it's fine enough. Soft delete in TypeORM seems like a feature that was added later in development, it's not documented very well. But so far it does work consistently enough so I think we can stick with it.

@GrahamS-Quartech GrahamS-Quartech merged commit 7ff66e1 into main May 23, 2024
@GrahamS-Quartech GrahamS-Quartech deleted the PIMS-1703-SoftDeletePropertiesProjects branch May 23, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants