Skip to content

refactor: drop the github identity from the users table - #1157

Draft
mnapoli wants to merge 1 commit into
feat/profilesfrom
feat/profiles-drop-user-columns
Draft

mnapoli wants to merge 1 commit into
feat/profilesfrom
feat/profiles-drop-user-columns

Conversation

@mnapoli

@mnapoli mnapoli commented Oct 25, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #1156, stacked on it. Profiles hold the GitHub identity of users, so the old copy on the users table goes.

Changes

  • Copies the identity of users who have no profile yet. Those are the users the old code signed up during the previous deploy.
  • Adds a foreign key from users.github_id to profiles.github_id, so every user has a profile.
  • Drops username, name, avatar_url, bio, location, website and github_synced_at from users.
  • Removes the tests that only wrote to those columns: the copy migration's test (a user without a profile can no longer exist) and the old mention-backfill migration's test (it read users.username).

Validation

Local, on a throwaway Postgres:

  • pest --parallel --ci --coverage --exactly=100.0: 4292 passed, 100% coverage.
  • StressSeeder (STRESS_SCALE=0.001) and OperationsSeeder run with the foreign key: every user has a profile.
  • Pint and Rector: no changes. PHPStan: the same 9 errors as on production.
  • Deploy simulation: migrated to the previous PR, inserted a user the way the old code would (no profile), then ran this migration. The user got a profile with their identity, and the columns dropped.

Independent review

Reviewed by a separate read-only agent. Verdict on 3273dab0: PASS. Its one low finding is applied in 3750058: the Tom "wrong identity" test now only gets the GitHub ID wrong, and it fails if TomQuery stops checking it.

Limitations

  • Deploy only once refactor: move the github identity of users to profiles #1156 is fully live: no web instances or queue workers left on older code. Older code still writes username and has no profiles, so sign-ups would fail on the foreign key.
  • Pre-deploy check: this read-only query on production should return 0. Otherwise the copy hits the unique handle and the migration rolls back.
    select count(*) from users u
    where not exists (select 1 from profiles p where p.github_id = u.github_id)
      and exists (select 1 from profiles p where p.handle = u.username);
  • No way back: the dropped columns can't come back without a new migration.

Profiles hold it since the previous change. The users signed up during that
deploy get their profile first, then every user must have one, through a
foreign key on their GitHub ID, and the unused columns go, along with the
tests that only wrote to them.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@mnapoli
mnapoli added this pull request to stack #1158 October 25, 2026 21:48
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