feat: dedicated permissions table#108
Merged
TorstenDittmann merged 18 commits intomainfrom Feb 21, 2022
Merged
Conversation
wess
approved these changes
Feb 18, 2022
eldadfux
reviewed
Feb 19, 2022
| $id = $this->filter($id); | ||
| $name = $this->filter($name); | ||
|
|
||
| return $this->getPDO() |
Member
There was a problem hiding this comment.
Do we know if this operation is locking the table?
Member
There was a problem hiding this comment.
After discussing this, we figured this is a blocking operation. We need to decide what we want to do with it. Although right now this is only used by migration, we might want to allow changing the attribute name directly from the Appwrite API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With this PR, every Collection will have a dedicated table with all its row level permissions.
The table has 4 columns:
_idinternal id (auto incremented)_typeeitherreadorwrite(possibility to extend in the future)_permissionthe actual permission value_documentreference to the_uidfor the documentNow that the Permissions are not saved within the actual row of a document anymore, we need to aggregate those informations. For this I am utilizing the JSON_ARRAYAGG function, which will automatically get all permissions for a Document and outputs it as a JSON array string.
In terms of performance there is very little to no impact and it also allows us to have data integrity over saving the permissions additionally with the document. Also the queries are written in a way to utilize Sub Query cache - which is enabled by default on MariaDB - which optimizes correlated subqueries by storing results together with correlation parameters in a cache and avoiding re-execution of the subquery in cases where the result is already in the cache.
The permissions table is appended with
_perms, not_permissionsto save space (we only have 64 chars of length for a table name).Query for getDocument:
Query for find: