-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add delete on cascade to fk_svc_inst_op_svc_instance_id #2905
Conversation
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
c581947
to
ea7d7e4
Compare
There was a problem hiding this 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.
db/migrations/20220805145100_add_delete_on_cascade_to_fk_svc_inst_op_svc_instance_id.rb
Outdated
Show resolved
Hide resolved
…, find by PK; as suggested
…perations, route binding operations and service key operations; as suggested
…#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.
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
Links to any other associated PRs
The root cause is fixed in this PR: Fix service instance operations duplicates root cause #2916
Add an unique index to service_instance_operations #2929
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests