Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/models/runtime/route_mapping_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def protocol_with_defaults

def validate
validates_presence [:app_port]
validates_unique %i[app_guid route_guid process_type app_port]

validate_weight
end
Expand All @@ -60,6 +59,15 @@ def has_app_port_specified?
app_port != ProcessModel::NO_APP_PORT_SPECIFIED
end

def around_save
yield
rescue Sequel::UniqueConstraintViolation => e
raise e unless e.message.include?('route_mappings_app_guid_route_guid_process_type_app_port_key')

errors.add(%i[app_guid route_guid process_type app_port], :unique)
raise validation_failed_error
end

private

def logger
Expand Down