Skip to content

Replacing validate uniqueness with db constraint on buildpack model#4942

Open
serdarozerr wants to merge 3 commits intocloudfoundry:mainfrom
sap-contributions:feature/replace-validate-uniqueness-with-db-constrain-on-buildpacks
Open

Replacing validate uniqueness with db constraint on buildpack model#4942
serdarozerr wants to merge 3 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
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
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.

2 participants