Enhanced Foreign Key Behavior
I am reaching out to share a suggestion regarding the current implementation of foreign key constraints in Firebase DataConnect.
Currently, it appears that the default behavior for foreign keys is automatically assigned during schema deployment, and there is no way to explicitly define ON DELETE and ON UPDATE rules (e.g., NO ACTION, CASCADE) in the GraphQL schema. This limitation has the following implications:
1. Deployment Overrides: Even if these rules are manually adjusted in the underlying PostgreSQL database, deploying an updated schema resets the rules to the platform’s defaults.
2. Lack of Customization in Schema: Adding support for directives like @relation(onDelete: NO_ACTION, onUpdate: CASCADE) would provide better control over foreign key behavior directly from the schema.
-
Mehmood Nadeemkhan commented
Hey firebase team that compatible thing dont work ir still show me the same brownfield error it match the SQL relationship with dataConnect and enforce me to change the SQL according to the DataConnect and your DataConnect have not the onDelete:RESTRICT and NO ACTION thing so i never match the SQL SCHEMA with the DATACONNECT so please tell me the solution and tell me how i do this thats urgent
-
Federico Baiocco commented
We are facing the same issue. We would like to set ON DELETE RESTRICT for some relations