Closed bernatvadell closed 5 months ago
Ah right good point. Will have to check this out a bit to see how to solve it.
I've encountered this error with our own sync system, flows/operations is unique as far as I can see having a circular reference. The only way I found to do it is to run in two passes with the first time omitting the resolve column.
Good news. This is now fixed in version 1.6.3
You would need to update the directus_config.json
file and add linkedFields
to directus_operations
:
{
directus_operations: {
watch: ['operations'],
excludeFields: ['user_created'],
linkedFields: ['resolve', 'reject'], // <<--- This tells the sync to check these two fields and order inserts accordingly
query: {
filter: {
flow: { trigger: { _neq: 'webhook' } },
},
},
},
}```
Describe the Bug
When importing the operations, they were exported without taking into account the order of dependencies. That is, if an operation "resolves" another operation, and it is inside the array, it is usually created later.
Console error:
To Reproduce
Deploy a new directus instance, create a flow with two connected operations. Install the library and export the data. You should see something like this:
In this case, the operation will be inserted first: 4d8c8f04-a8b3-4f99-a64c-51a9574280d7, and this has in the resolve column the operation: "d3ebf874-55a2-4b27-bcf0-95171bb10146" which, as it does not yet exist in the database , will give an FK error.
I had thought that it might be interesting to disable the FKs during the synchronization process, and enable them again once it is finished. In case of error, we would rollback the transaction.
Version
1.6.1
Installed Extension Via
NPM Custom