Maven virtual registry: relax the _iv unique constraint in the upstreams table

🔥 Problem

In Add dedicated credentials columns for Maven Ups... (!171702 - merged), we split a single encrypted column which contain a json structure (with two keys: username, password) into 2 dedicated encrypted columns: username, password.

Since they are encrypted, we also added the _iv columns. These columns should be unique (in order to increase the overall security).

The problem is that we missed that these columns could be empty (so set to NULL) since the username + password are optional.

We certainly don't want to have a single record with NULL _iv. We will have multiple records that will not have these columns set.

🚒 Solution

  • Properly fix the constraint to not apply it for cases where the _iv columns are NULL
  • Add a case in the specs to assert this behavior.