Skip to content

Conversation

@irshadaj
Copy link
Contributor

@irshadaj irshadaj commented Nov 14, 2023

Description

Currently, the name field of an asset group selector needs to be unique regardless of the asset group. This prevents custom “High Value” nodes from being added to the “Owned” group and vice versa in BHCE, and would cause further problems if we want to add additional groups in the future. Trying to add a duplicate selector causes an error.

This story drops that constraint and creates a new uniqueness constraint on both the name and asset_group_id columns, thereby allowing a selector to exist under both Owned as well as HVT asset groups.

How Has This Been Tested?

I spun up a database on the main branch to simulate an existing DB. The selectors table has a constraint on the name column here:

existing constraints

Then I restarted the environment to have the migration applied:

existing migration execution

Verified that the constraint has been updated (the new constraint name contains both column names in it):

existing constraints after

Then I created 2 selectors with the same name but belonging to the 2 different asset groups via postman:

existing owned existing t0

And verified through the database that both the selectors were created:

existing db

Next, I wiped out my database and re-created it to verify that any fresh installs will have the right constraint set up, and then repeated the selecor creation via postman to verify that multiple selectors can exist with the same name:

fresh owned fresh t0 fresh db

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • My changes include a database migration.

@irshadaj irshadaj requested a review from superlinkx November 14, 2023 19:47
@irshadaj irshadaj self-assigned this Nov 14, 2023
@irshadaj irshadaj force-pushed the selectors_uniqueness_fix branch from 5fac966 to 968ac5b Compare November 14, 2023 19:56
zinic
zinic previously requested changes Nov 14, 2023
Copy link
Contributor

@zinic zinic left a comment

Choose a reason for hiding this comment

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

Left a comment on the DROP CONSTRAINT SQL statement. Changes otherwise look good.

@irshadaj irshadaj force-pushed the selectors_uniqueness_fix branch from d95b1b5 to 5f2e7ce Compare November 14, 2023 22:12
@superlinkx superlinkx requested a review from zinic November 14, 2023 23:13
@superlinkx superlinkx dismissed zinic’s stale review November 15, 2023 19:06

Changes were made accordingly, unblocking PR

@superlinkx
Copy link
Contributor

Looks good, feel free to pull

Copy link
Contributor

@zinic zinic left a comment

Choose a reason for hiding this comment

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

Pull!

@irshadaj irshadaj merged commit 7fbc37e into main Nov 15, 2023
@irshadaj irshadaj deleted the selectors_uniqueness_fix branch November 15, 2023 21:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants