Skip to content

Account merging DB migration#7686

Draft
XiNiHa wants to merge 2 commits intomainfrom
CONSOLE-1756
Draft

Account merging DB migration#7686
XiNiHa wants to merge 2 commits intomainfrom
CONSOLE-1756

Conversation

@XiNiHa
Copy link
Member

@XiNiHa XiNiHa commented Feb 12, 2026

Background

While new users are already getting benefits from account linking introduced in #7390, existing users who already have duplicated accounts have not yet had their accounts merged.

Description

Adds a DB migration that merges existing users with the same email into a single user, with multiple auth methods linked.

Checklist

  • Input validation
  • Output encoding
  • Authentication management
  • Session management
  • Access control
  • Cryptographic practices
  • Error handling and logging
  • Data protection
  • Communication security
  • System configuration
  • Database security
  • File management
  • Memory management
  • Testing

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @XiNiHa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new database migration script aimed at consolidating duplicate user accounts within the system. The migration identifies users sharing the same email address and merges their associated data, with a particular focus on resolving and merging organization memberships and their respective roles. The goal is to maintain data integrity and consistency by ensuring all related records point to a single, primary user account after the consolidation process.

Highlights

  • New Database Migration: Introduced a new database migration script (2026.02.10T00-00-00.account-merging.ts) to handle the merging of duplicate user accounts based on their email addresses.
  • User Account Merging Logic: Implemented a process to identify users with the same email and consolidate them into a single primary user, iterating through users in batches.
  • Organization Membership Merging: Developed a complex strategy for merging organization_member records associated with duplicate users, ensuring that memberships are correctly attributed to the primary user. This includes logic for handling single memberships and merging multiple memberships into the oldest one.
  • Role Determination Strategy: Incorporated a detailed role determination process during membership merging, prioritizing 'Admin' roles, then checking for unique roles, unique non-viewer roles, and attempting to find a superset role based on scopes or permissions. This section contains TODO comments for further refinement.
  • Foreign Key Updates: Updated users_linked_identities to point to the primary user's ID for all merged user accounts, with a TODO for additional foreign key rewrites.
Changelog
  • packages/migrations/src/actions/2026.02.10T00-00-00.account-merging.ts
    • Added a new database migration script to merge duplicate user accounts based on email.
    • Implemented logic for merging organization memberships and determining the appropriate role for the primary user.
    • Included updates for users_linked_identities to reflect merged user IDs.
Activity
  • The pull request description is currently marked with 'TODO: fill this in', indicating that a detailed explanation from the author is pending.
  • The provided checklist for PR quality is largely unchecked, suggesting the pull request is in an early or draft stage of development.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
hive 9.4.1-alpha-20260219152815-f13e480ba72c96d0d3a049541dfbd9bdfb78e8b9 npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: f007125671f2c24f06b341a432276ff15e06ea64

gemini-code-assist[bot]

This comment was marked as outdated.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

💻 Website Preview

The latest changes are available as preview in: https://pr-7686.hive-landing-page.pages.dev

gemini-code-assist[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant