fix: add unique index on users that are not deleted - #309
Open
karimouf wants to merge 1 commit into
Open
Conversation
dennis-zyska
requested changes
Jul 31, 2026
dennis-zyska
left a comment
Collaborator
There was a problem hiding this comment.
We should add a huge number of columns for that, have a look here: https://github.com/UKPLab/CARE/blob/dev/backend/db/migrations/20251005114112-transform-document_data.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New user-facing behaviour
Improvements
user.email,userName,extId,orcidId, andsamlNameIdis now scoped to active (deleted = false) rows via a partial unique index, matching the existing app-level logic (filterExistingEmails) instead of contradicting itBug fixes
extId,orcidId, orsamlNameIdthat belonged to a soft-deleted account failed withSequelizeUniqueConstraintError, even though the app treated that value as availableKnown limitations
deleted = false) must not assume email or username is globally uniquedown) re-adds a plain unique constraint and will fail if an active + deleted row pair with a duplicate value exists at that pointFuture steps
WHERE deleted = false) by default, rather than each column needing its own one-off migration — e.g. a shared migration helper or a lint/CI check that flags a plainunique: trueon a column in a table that also has adeletedcolumn