rafiki icon indicating copy to clipboard operation
rafiki copied to clipboard

feat(2589): soft delete unused asset

Open lengyel-arpad85 opened this issue 1 year ago • 6 comments

Soft delete asset including the Admin frontend part, by adding a deletedAt date and filtering get & getAll calls for deletedAt being NULL This approach was adopted instead of hard delete since TigerBeetle has no support for deleting rows

Checklist

  • [ ] Related issues linked using fixes #number
  • [x] Tests added/updated
  • [ ] Documentation added
  • [x] Make sure that all checks pass
  • [x] Bruno collection updated

lengyel-arpad85 avatar May 03 '24 09:05 lengyel-arpad85

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
Latest commit bdc5e1b1ac74df203af21ef24c15586970dd5077
Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/66525ff288f2810008a91358

netlify[bot] avatar May 03 '24 09:05 netlify[bot]

My main question is, what should we do when we delete an asset, then try to re-create another one with the same code and scale (via createAsset mutation)?

Right now, we will get a "duplicate asset" error, but that might be a bit confusing given the asset isn't visible in the UI. Maybe we can just set deletedAt to be null again, and return the asset?

yes, that might work, but if the scale is different from what we had before, do we just update the scale to the new one ?

lengyel-arpad85 avatar May 07 '24 10:05 lengyel-arpad85

@arpad-lengyel

yes, that might work, but if the scale is different from what we had before, do we just update the scale to the new one ?

An asset is unique on scale and code together, so that would signify a new/different asset

mkurapov avatar May 08 '24 10:05 mkurapov

@arpad-lengyel

yes, that might work, but if the scale is different from what we had before, do we just update the scale to the new one ?

An asset is unique on scale and code together, so that would signify a new/different asset

@mkurapov It's an unused asset, so in theory it should not matter what the previous scale was, it was never used, so it won't have an effect on anything, no ?

lengyel-arpad85 avatar May 08 '24 10:05 lengyel-arpad85

It's an unused asset, so in theory it should not matter what the previous scale was, it was never used, so it won't have an effect on anything, no ?

Right, however I would say to be safe, we should treat e.g. USD/9 vs USD/2 as completely different assets (even if they have the same asset code). This is reflected in the DB as well:

https://github.com/interledger/rafiki/blob/8835414f0f478b30ab7ee80a54e8af39ac3b1904/packages/backend/migrations/20210422194130_create_assets_table.js#L15

mkurapov avatar May 10 '24 13:05 mkurapov

It's an unused asset, so in theory it should not matter what the previous scale was, it was never used, so it won't have an effect on anything, no ?

Right, however I would say to be safe, we should treat e.g. USD/9 vs USD/2 as completely different assets (even if they have the same asset code). This is reflected in the DB as well:

https://github.com/interledger/rafiki/blob/8835414f0f478b30ab7ee80a54e8af39ac3b1904/packages/backend/migrations/20210422194130_create_assets_table.js#L15

yes, you are right, I've corrected the condition in my code

lengyel-arpad85 avatar May 13 '24 07:05 lengyel-arpad85