Skip to content

fix(controlplane): support soft-deleted items on name constraint - #613

Merged
migmartri merged 2 commits into
chainloop-dev:mainfrom
migmartri:fix-soft-deletion
Mar 13, 2024
Merged

fix(controlplane): support soft-deleted items on name constraint#613
migmartri merged 2 commits into
chainloop-dev:mainfrom
migmartri:fix-soft-deletion

Conversation

@migmartri

Copy link
Copy Markdown
Member

Take into account the deleted_at column in the uniqueness constraint

Closes #612

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
@migmartri
migmartri requested a review from danlishka March 13, 2024 12:00
index.Fields("name").Edges("organization").Unique(),
// names are unique within a organization and affects only to non-deleted items
index.Fields("name").Edges("organization").Unique().Annotations(
entsql.IndexWhere("deleted_at IS NULL"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the important bit

@migmartri
migmartri requested a review from tknura March 13, 2024 12:06

@danlishka danlishka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@migmartri
migmartri merged commit 09ebb28 into chainloop-dev:main Mar 13, 2024
@migmartri
migmartri deleted the fix-soft-deletion branch March 13, 2024 12:31
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.

make sure uniqueness take into account soft-deleted items

2 participants