Skip to content

Remove not needed validates_unique for route mappings - #4620

Merged
johha merged 1 commit into
mainfrom
remove-not-needed-unique-validation
Oct 28, 2025
Merged

Remove not needed validates_unique for route mappings#4620
johha merged 1 commit into
mainfrom
remove-not-needed-unique-validation

Conversation

@johha

@johha johha commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Table route_mappings has a unique constraint for columns app_guid, route_guid, process_type and app_port. Therefore we can rely on the DB to catch uniqueness errors and remove the sequel validates_unique in the model. This reduces the number of DB queries as the following query is now skipped:

SELECT 1 AS \"one\" FROM \"route_mappings\" WHERE ((\"app_guid\" = <app_guid>) AND (\"route_guid\" = <route_guid>) AND (\"process_type\" = 'web') AND (\"app_port\" = <port>)) LIMIT 1"
  • 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 branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Table `route_mappings` has a unique constraint for columns `app_guid`, `route_guid`, `process_type` and `app_port`.
Therefore we can rely on the DB to catch uniqueness errors and remove the sequel `validates_unique` in the model.
This reduces the number of DB queries as the following query is now skipped:

```SQL
SELECT 1 AS \"one\" FROM \"route_mappings\" WHERE ((\"app_guid\" = <app_guid>) AND (\"route_guid\" = <route_guid>) AND (\"process_type\" = 'web') AND (\"app_port\" = <port>)) LIMIT 1"
```
@johha
johha marked this pull request as ready for review October 27, 2025 12:17
@johha
johha requested a review from a team October 27, 2025 12:18
@johha
johha merged commit b6d5357 into main Oct 28, 2025
11 checks passed
@johha
johha deleted the remove-not-needed-unique-validation branch October 28, 2025 12:39
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Oct 28, 2025
Changes in cloud_controller_ng:

- Remove not needed `validates_unique` for route mappings
    PR: cloudfoundry/cloud_controller_ng#4620
    Author: Johannes Haass <johannes.haass@sap.com>
sethboyles pushed a commit to atanas-attodorov-wq/cloud_controller_ng that referenced this pull request Dec 11, 2025
…#4620)

Table `route_mappings` has a unique constraint for columns `app_guid`, `route_guid`, `process_type` and `app_port`.
Therefore we can rely on the DB to catch uniqueness errors and remove the sequel `validates_unique` in the model.
This reduces the number of DB queries as the following query is now skipped:

```SQL
SELECT 1 AS \"one\" FROM \"route_mappings\" WHERE ((\"app_guid\" = <app_guid>) AND (\"route_guid\" = <route_guid>) AND (\"process_type\" = 'web') AND (\"app_port\" = <port>)) LIMIT 1"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants