add ON DELETE CASCADE to routes during delete of service #7314
Replies: 2 comments
-
We have kong/kong/db/schema/entities/plugins.lua Lines 18 to 20 in 28e4baf |
Beta Was this translation helpful? Give feedback.
-
The one thing about cascades that worries me is the cache. I think we might have some problems with it already. This same problem is probably also with caching entities that have ttl for longer than ttl. As deletions happen on DB level, there is no |
Beta Was this translation helpful? Give feedback.
-
Summary
Suggestion to cascade delete routes when deleting a service. If a service has a lot of routes, it is painful to get
/services/:service/routes
and thenDELETE /routes/:id
. Was not able to see any historical significance of not having cascade delete of routes when deleting a service, and it seems that sometimes we cascade delete other entities. For example, if you create a plugin on a service, then deleting the service also deletes the plugin. @thibaultcha mentioned that we might want to allow for dangling routes while deleting the service so that the router never produces invalid responses. Could this be circumvented by disassociating the service from the route before performing the service delete?Added migration locally and tested to success:
It is nice to have safety guards during
DELETE
of services since you could be performing a very destructive action, so curious if it is better to "opt-in" by not creating the DB association but handling at the ORM level e.g.DELETE /services/:service/routes?cascade=true
. This is setup in other ORM's like e.g. doctrine's cascade="remove" and orphanRemoval so that you would opt-in to the relationship deletion.Beta Was this translation helpful? Give feedback.
All reactions