A proposal to uuid managing #613
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Title: Add deterministic, reversible UUID helper for model IDs
This PR introduces a small utility that generates deterministic UUIDs from a numeric model ID plus the model name, while allowing the original numeric ID to be recovered on the server side.
What is the idea
The intent of this PR is to solve the public UUIDs requirement with no changes neither, on DB or in the models. We can calculate fixed UUIDs and manage them in execution time. By the generation of deterministic UUIDs as output from a function, being capable of revert their state and to recover the original, the application is able to add a calculated attribute called "public_id" that differs substantially from the DB numeric ID. Furthermore, it generates the possibility of - by reverting the UUID to its original form - communicate the external inputs with the internal DB.
Rationale
For this project we need UUIDs that:
(numeric_id, model_name)pair.By encrypting a single 16‑byte block with AES and treating the ciphertext as a UUID, we get a reversible mapping controlled by a secret key that lives in configuration rather than in the database schema.
Notes
UUID_AES_KEYwill change the mapping for all existing UUIDs, so deployments should treat this key similarly toSECRET_KEYand keep it stable.A simple demostration
Checklist
djLint-er on any new code
changes
What type of PR is this?
Added/updated tests?
Related PRs, Issues etc