#Some Best Practises
1 messages · Page 1 of 1 (latest)
Hi @prisma mango , here are the answers to your questions above. These are the best practices we've seen from other users who have applied them, but for your unique case, they might not be sufficient. If so, please let us know for further discussion.
Best practice for transactional creation? (For example, im creating a user in my db, and need to add also to permify - how to ensure that the data will be consistent?)
To create authorization data (relationships or attributes), you can use the WriteAPI (https://docs.permify.co/docs/api-overview/data/write-data/#write-request) or Write Bundle (https://docs.permify.co/docs/api-overview/bundle/write-bundle/) if you need to perform predefined actions that results several data creation. As a best practice for consistency & data creation, we suggest incorporating the write request into the database transaction of the corresponding client action.You can learn more about this suggested workflow in our docs (https://docs.permify.co/docs/api-overview/data/write-data/#suggested-workflow)
How to perform migrations through the schema and more important through data. Any tutorials, best practices?
We recommend applying the following pattern to safely handle schema changes, also stated in our docs (https://docs.permify.co/docs/api-overview/schema/write-schema/#suggested-workflow-for-schema-changes)
- Set up a central git repository that includes the schema. Teams or individuals who need to update the schema should add new permissions or relations to this repository.
- Centrally check and approve every change before deploying it via CI pipeline that utilizes the Write Schema API. We recommend adding our schema validator to the pipeline to ensure that any changes are automatically validated.
- After successful deployment, you can use the newly created schema on further API calls by either specifying its schema ID or by not providing any schema ID, which will automatically retrieve the latest schema on API calls.
How to perform periodic cleanup. (For example, user is deleted from main DB, somewhy and somehow, so i want to delete it from permify also, to make data consistent)
In Permify, the authorization data (relationships or attributes) won't be deleted unless you specifically do so using the Delete API (https://docs.permify.co/docs/api-overview/data/delete-data/) or the Delete Bundle (https://docs.permify.co/docs/api-overview/bundle/delete-bundle/). These operations softly delete the data. To permanently remove them after a specific time period, we have a Garbage Collector, which you can configure: https://docs.permify.co/docs/reference/configuration/#definition-5
@fringe rapids
-
Don't you think that making http requests inside a DB transaction is antipattern? I can basically lock the table for tens of seconds if http request to permify is stuck?
-
For example I have relation
admin @user, and now i need to havemanager @userinstead of it.
How do I update all users from beingadmininto beingmanager? -
Is cascade delition is upported? Means - if i delete
organization- it means that all tuples that say thatuser:1 is admin of organizationwill be deleted automatically?