foreign key constraint
Syncing stops because of foreign key constraint between two collections. directus-extension-sync shows error in console and crashes.
Solution would be to run "SET FOREIGN_KEY_CHECKS=0;" before pushing to DB, and then "SET FOREIGN_KEY_CHECKS=1;" when push is done. But how to set these additional DB commands in config or directus-extension-sync module itself?
errors: [
{
"message": "alter table cluster_analysis_data modify product int null - Cannot change column 'product': used in a foreign key constraint 'cluster_analysis_data_product_foreign'",
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
response: {}
Hi @boo-code
Solution would be to run "SET FOREIGN_KEY_CHECKS=0;" before pushing to DB, and then "SET FOREIGN_KEY_CHECKS=1;" when push is done. But how to set these additional DB commands in config or directus-extension-sync module itself?
No, you can't inject DB commands during push.
It seems that you are trying to run a migration of schema with existing data. This is related to the schema snapshot of Directus, used by Directus-Sync.
Destination is completely empty and has no data at all. I should check something in source here where pull was made from?
If destination database is empty, sync is working. If destination already contains tables (even empty from first sync), sync stops because of foreign key constraints.
could be related with this issue?
https://github.com/directus/directus/issues/24961#issuecomment-2863363053