Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove provider users for deleted identities #3399

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

BruceMacD
Copy link
Collaborator

Summary

This should be merged after #3398
When an identity was deleted through the CLI the associated provider user was not deleted. This migration cleans up provider_user records that reference a deleted identity.

Checklist

  • Wrote appropriate unit tests
  • Considered security implications of the change
  • Change is backwards compatible if it needs to be (user can upgrade without manual steps?)
  • Nothing sensitive logged
  • Considered data migrations for smooth upgrades

Related Issues

Resolves #3397

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 749 to 751
err := db.QueryRow(`SELECT identity_id FROM provider_users`).Scan(&remainingProviderUser)
assert.NilError(t, err)
assert.Equal(t, remainingProviderUser, uid.ID(2222))
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: I think this test could pass even when the first record is not deleted, if the DB decided to return the records in a different order than we expect. I'm not sure if that's possible.
Another option might be to SELECT count(*) from provider_users where identity_id = 1111 which should give us a count of 0.

@BruceMacD BruceMacD force-pushed the brucemacd/remove-provider-users-deleted-identity branch from 88692bf to ed32617 Compare October 7, 2022 13:33
@BruceMacD BruceMacD merged commit d924dbc into main Oct 11, 2022
@BruceMacD BruceMacD deleted the brucemacd/remove-provider-users-deleted-identity branch October 11, 2022 15:20
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.

When an identity is soft-deleted provider user records should be removed
2 participants