LF-5197: Account deletion: add migration and update UserModel#4090
Open
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
Open
LF-5197: Account deletion: add migration and update UserModel#4090litefarm-pr-bot wants to merge 1 commit intointegrationfrom
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
Conversation
Add a Knex migration that adds `deleted` (boolean NOT NULL DEFAULT false) and `google_sub` (varchar NULL) columns to the `users` table, backfills `google_sub` from `user_id` for existing SSO users whose user_id is numeric, and adds an index on `google_sub`. Update UserModel jsonSchema and hidden array to include both new fields so they are validated but not returned in API responses by default. Also fix pre-existing no-unused-expressions lint errors in the same file. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Description
Prior to this change, the
userstable had nodeletedflag and no dedicated column for storing a Google OAuth subject identifier. SSO users were identified by their numeric Google sub stored directly asuser_id, which conflates authentication identity with the application's primary key. To support migrating SSO users to UUID-baseduser_ids (part of LF-5193), the Google sub must be stored separately so it can continue to be used for identity lookup after the migration.This PR adds a Knex migration that introduces
deleted boolean NOT NULL DEFAULT falseandgoogle_sub varchar NULLto theuserstable. It backfillsgoogle_subfromuser_idfor all existing rows whereuser_idis numeric (i.e. current SSO users), then adds an index ongoogle_subto support efficient lookups. TheUserModeljsonSchemais updated to recognise both new columns for validation, and both are added to thehiddenarray so they are stripped from API responses by default. Pre-existing@typescript-eslint/no-unused-expressionslint errors in the same file (short-circuit assignment idioms) are also fixed to keep the file passing ESLint.Going forward, any new column added to
usersthat should not appear in API responses must be listed inUserModel.hidden. Thegoogle_subcolumn is intentionally nullable so that non-SSO (email/password) users have a null value.Implements sub-task LF-5197, part of LF-5193.
Jira link: https://lite-farm.atlassian.net/browse/LF-5197
Type of change
How Has This Been Tested?
Migration and model changes reviewed in source code. No local database running; migration was not executed against a live DB. Pre-commit lint and Prettier hooks passed successfully on commit.
Checklist:
pnpm i18nto help with this)