Skip to content

Conversation

@alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented Jan 2, 2026

What does this PR do?

This PR introduces a schema change to support efficient domain-based operations without relying on string parsing or in-memory user ID lists at query time.

Specifically, it:

  • Adds a nullable email_domain column to users and SecondaryEmail
  • Introduces database triggers to automatically populate email_domain on future inserts and email updates
  • Establishes a safe foundation for indexed, DB-side domain filtering without impacting existing rows or requiring backfill in this PR

This PR intentionally does not backfill existing rows to avoid long-running locks or table rewrites. Historical backfill and index creation will be handled separately.

Fixes #XXXX

Fixes CAL-XXXX

Visual Demo (For contributors especially)

N/A — database-only schema change with no UI or behavior changes exposed yet.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A I have updated the developer docs in /docs if this PR makes changes that would require a documentation change.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This change is verified at the database level.

Manual verification steps:

  • Insert a new user with an email containing a valid domain.
  • Confirm email_domain is automatically populated with the lowercase domain portion.
  • Update an existing user’s email and verify email_domain updates accordingly.
  • Repeat the above for SecondaryEmail.

Expected behavior:

  • New and updated rows correctly populate email_domain

  • Existing rows remain unchanged (email_domain = NULL)

  • No application-level logic is required to manage domain normalization

  • Environment variables: None

  • Minimal test data: A single user and secondary email record

  • Happy path: email = [email protected] → email_domain = domain.com

Checklist

@alishaz-polymath alishaz-polymath requested a review from a team as a code owner January 2, 2026 13:35
@graphite-app graphite-app bot added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jan 2, 2026
@graphite-app graphite-app bot requested a review from a team January 2, 2026 13:36
@github-actions github-actions bot added the ❗️ migrations contains migration files label Jan 2, 2026
cubic-dev-ai[bot]

This comment was marked as resolved.

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Review Updated (UTC)
cal Ignored Ignored Jan 2, 2026 2:03pm
cal-companion Ignored Ignored Preview Jan 2, 2026 2:03pm
cal-eu Ignored Ignored Jan 2, 2026 2:03pm

@alishaz-polymath
Copy link
Member Author

Closing in Favor of alternate approach

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

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ❗️ migrations contains migration files ready-for-e2e size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants