Skip to content

LF-5197: Account deletion: add migration and update UserModel#4090

Open
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
LF-5197-add-migration-and-update-usermodel
Open

LF-5197: Account deletion: add migration and update UserModel#4090
litefarm-pr-bot wants to merge 1 commit intointegrationfrom
LF-5197-add-migration-and-update-usermodel

Conversation

@litefarm-pr-bot
Copy link
Collaborator

Description

Prior to this change, the users table had no deleted flag and no dedicated column for storing a Google OAuth subject identifier. SSO users were identified by their numeric Google sub stored directly as user_id, which conflates authentication identity with the application's primary key. To support migrating SSO users to UUID-based user_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 false and google_sub varchar NULL to the users table. It backfills google_sub from user_id for all existing rows where user_id is numeric (i.e. current SSO users), then adds an index on google_sub to support efficient lookups. The UserModel jsonSchema is updated to recognise both new columns for validation, and both are added to the hidden array so they are stripped from API responses by default. Pre-existing @typescript-eslint/no-unused-expressions lint 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 users that should not appear in API responses must be listed in UserModel.hidden. The google_sub column 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

  • 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 not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

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:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

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]>
@litefarm-pr-bot litefarm-pr-bot requested review from a team as code owners March 16, 2026 20:46
@litefarm-pr-bot litefarm-pr-bot requested review from kathyavini and removed request for a team March 16, 2026 20:46
@kathyavini kathyavini changed the title LF-5197: Add migration and update UserModel LF-5197: Account deletion: add migration and update UserModel Mar 17, 2026
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.

1 participant