Skip to content

Replacing validate uniqueness with db constraint on Buildpack model#4942

Merged
philippthun merged 6 commits intocloudfoundry:mainfrom
sap-contributions:feature/replace-validate-uniqueness-with-db-constrain-on-buildpacks
Mar 24, 2026
Merged

Replacing validate uniqueness with db constraint on Buildpack model#4942
philippthun merged 6 commits intocloudfoundry:mainfrom
sap-contributions:feature/replace-validate-uniqueness-with-db-constrain-on-buildpacks

Conversation

@serdarozerr
Copy link
Contributor

Replaces the Sequel validates_unique check with a DB-level unique index on (name, stack, lifecycle). The around_save hook catches UniqueConstraintViolation and converts it to ValidationFailed, making uniqueness enforcement race-condition safe.

Changes

  • Migration: Cleans duplicate rows, drops old unique_name_and_stack index, adds new buildpacks_name_stack_lifecycle_index (idempotent)
  • Model: Removed validates_unique, added around_save for DB-level enforcement
  • Specs: Migration spec (index swap, idempotency, duplicate cleanup) + updated model uniqueness tests
  • 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

@serdarozerr serdarozerr marked this pull request as ready for review March 20, 2026 09:44
johha
johha previously approved these changes Mar 20, 2026
Copy link
Contributor

@johha johha left a comment

Choose a reason for hiding this comment

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

LGTM

@johha johha requested review from a team and philippthun March 20, 2026 11:50
@serdarozerr serdarozerr changed the title Replacing validate uniqueness with db constraint on buildpack model Replacing validate uniqueness with db constraint on Buildpack model Mar 23, 2026
@philippthun philippthun merged commit 2fe1ab6 into cloudfoundry:main Mar 24, 2026
16 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Mar 24, 2026
Changes in cloud_controller_ng:

- Replacing validate uniqueness with db constraint on Buildpack model
    PR: cloudfoundry/cloud_controller_ng#4942
    Author: serdar özer <[email protected]>
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