Skip to content

Commit f75acb0

Browse files
authored
Ignore unique errors for domain, route & service instances (#4641)
Commit `8b932f9f9498d2d222b981aa7dc5db7a6d16dcf7` (PR #4611) introduced the option to ignore `UniqueConstraintViolation`` errors for specified indexes/ constraints/ keys. This change does the same for the domain, route and service instance model. The ignore logic is already tested in the vcap_relations plugin (see #4611).
1 parent 6c6d792 commit f75acb0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

app/models/runtime/domain.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def shared_or_owned_by(organization_ids)
6767
join_table: 'organizations_private_domains',
6868
left_key: :private_domain_id,
6969
right_key: :organization_id,
70-
before_add: :validate_add_shared_organization
70+
before_add: :validate_add_shared_organization,
71+
ignored_unique_constraint_violation_errors: %w[orgs_pd_ids]
7172
)
7273

7374
add_association_dependencies(

app/models/runtime/route.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class InvalidOrganizationRelation < CloudController::Errors::InvalidRelation; en
3131
right_key: :target_space_guid,
3232
right_primary_key: :guid,
3333
join_table: :route_shares,
34-
class: VCAP::CloudController::Space
34+
class: VCAP::CloudController::Space,
35+
ignored_unique_constraint_violation_errors: %w[route_shares.PRIMARY route_target_space_pk]
3536

3637
one_to_one :route_binding
3738
one_through_one :service_instance, join_table: :route_bindings

app/models/services/service_instance.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class InvalidServiceBinding < StandardError; end
4242
right_key: :target_space_guid,
4343
right_primary_key: :guid,
4444
join_table: :service_instance_shares,
45-
class: VCAP::CloudController::Space
45+
class: VCAP::CloudController::Space,
46+
ignored_unique_constraint_violation_errors: %w[service_instance_shares.PRIMARY service_instance_target_space_pk]
4647

4748
many_to_many :routes, join_table: :route_bindings
4849

0 commit comments

Comments
 (0)