-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
-
Goal: Simplify the usage of user IDs because now co-exists two different IDs for users and creates some unnecessary complexities.
-
TLDR: The two IDs that exist are (
oauth_provider,oauth_user_id) andpublic_id, after this update auto-drive backend won't have a reference to eitheroauth_provideroroauth_user_id
Data Model Update
-
Migration 1 — Add and backfill
public_id:- Add a new nullable
public_idcolumn to every table that currently uses(oauth_provider, oauth_user_id). - Backfill
public_idfor existing rows by computing it with@generateUserPublicIdfrom the pair(oauth_provider, oauth_user_id). - Keep existing constraints in place during backfill. Optionally add indexes on
public_idwhere lookups will happen.
- Add a new nullable
-
Migration 2 — Remove oauth columns and enforce
public_id:- Remove the
oauth_user_idcolumn(s) from those tables. - Make the new
public_idcolumnNOT NULLand update any keys/constraints to usepublic_id.
- Remove the
-
Notes:
@generateUserPublicIdis the existing helper used to deterministically derive thepublic_idfrom(oauth_provider, oauth_user_id)and should be used for the backfill step.- Apply this to all tables that currently key or reference users by the oauth pair.
Models updates
- Replace all
oauthProvider/oauthUserIdusages with a singlepublicIdin domain types and DTOs.objects/object.ts:Owner→{ publicId: string; role }(remove oauth fields).uploads/upload.ts: table shape usespublic_id; model shape/schemas usepublicId. UpdatefileUploadSchema/folderUploadSchema,UploadEntry, and mappers accordingly.users/apiKey.ts: replace oauth fields withpublicId: string.users/jwt.ts: payloads includepublicId; remove oauth fields and Hasura claimsx-hasura-oauth-*. Keepx-hasura-public-id.users/user.ts: makepublicIdthe primary identifier; keepOAuthUseronly for provider-bound data.
- Naming: DB-facing structs use
public_id(snake_case); model-facing types usepublicId(camelCase). - Versioning: mark as breaking change and bump models package major; update tests/fixtures.
Hasura updates
- In
tables/object_ownerships.yml: Replaceoauth_*columns forpublic_id - In filter like in
tables/async_downloads.yml: Replaceoauth_*columns forpublic_idin filters
GraphQL updates
- Some queries use
oauth_*matching the current schema, these queries should be updated too