Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete on cascade to fk_svc_inst_op_svc_instance_id #2905

Conversation

kathap
Copy link
Contributor

@kathap kathap commented Aug 5, 2022

We can see double entries for the same service_instance_id
in the service_instance_operations table. This leads to:
PG::ForeignKeyViolation: ERROR: update or delete on table
"service_instances" violates foreign key constraint
"fk_svc_inst_op_svc_instance_id" on table "service_instance_operations"

For service bindings, service keys and route bindings the foreign
key constraint from operation to resource contains ON DELETE CASCADE;
for service instances this is missing.

Adding ON DELETE CASCADE to FK fk_svc_inst_op_svc_instance_id in
service_instance_operations

@kathap kathap marked this pull request as draft August 5, 2022 11:46
We can see double entries for the same service_instance_id
in the service_instance_operations table. This leads to:
PG::ForeignKeyViolation: ERROR:  update or delete on table
"service_instances" violates foreign key constraint
"fk_svc_inst_op_svc_instance_id" on table "service_instance_operations"

For service bindings, service keys and route bindings the foreign
key constraint from operation to resource contains ON DELETE CASCADE;
for service instances this is missing.

Adding ON DELETE CASCADE to FK fk_svc_inst_op_svc_instance_id in
service_instance_operations
@kathap kathap force-pushed the add-delete-on-cascade-to-svc-inst-op-fk branch from c581947 to ea7d7e4 Compare August 29, 2022 08:33
@kathap kathap marked this pull request as ready for review August 29, 2022 09:49
@kathap kathap marked this pull request as draft August 29, 2022 11:09
@kathap kathap marked this pull request as ready for review August 31, 2022 10:02
Copy link
Member

@philippthun philippthun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added test passes even without the migration. The reason for this is the following line in app/models/services/service_instance.rb:

add_association_dependencies service_instance_operation: :destroy

I would propose to remove this 'association dependency' (then the test should fail without the new migration). This would mean that service instance operations would be consistent with service binding operations, route binding operations and service key operations - they also do not have such an 'association dependency' and use DELETE CASCADE instead.

…perations, route binding operations and service key operations; as suggested
@philippthun philippthun merged commit 91c805e into cloudfoundry:main Sep 13, 2022
will-gant pushed a commit to sap-contributions/cloud_controller_ng that referenced this pull request Dec 16, 2022
…#2905)

We can see double entries for the same service_instance_id
in the service_instance_operations table. This leads to:
PG::ForeignKeyViolation: ERROR:  update or delete on table
"service_instances" violates foreign key constraint
"fk_svc_inst_op_svc_instance_id" on table "service_instance_operations"

For service bindings, service keys and route bindings the foreign
key constraint from operation to resource contains ON DELETE CASCADE;
for service instances this is missing.

Adding ON DELETE CASCADE to FK fk_svc_inst_op_svc_instance_id in
service_instance_operations

Remove association dependency to be consistent with service binding
operations, route binding operations and service key operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants