How can I ensure that user id are unique even after deletion ?

I want to share user id with third party services like revenuecat, however in my app i allow user to remove account then the uid could be assigned to another user (very unlikely as the risk of collision is very low) but i have to handle this case.

My idea is to create a table with shared_uid and user_id columns.
Each time a user is inserted a new row will be inserted in the table.
When the user_id is removed , i set it to null then the shared_uid will remain in the table.

As well it adds an extra layer of anonymization like other services will not know the internal user IDs.

Do you think it's a good idea ? Or overengineering maybe ?
Was this page helpful?