Skip to content

refactor(identity): rename provider_id to external_account_id and restructure schema#186

Merged
danielhe4rt merged 2 commits into4.xfrom
refactor/external-identity-schema
Mar 21, 2026
Merged

refactor(identity): rename provider_id to external_account_id and restructure schema#186
danielhe4rt merged 2 commits into4.xfrom
refactor/external-identity-schema

Conversation

@danielhe4rt
Copy link
Contributor

@danielhe4rt danielhe4rt commented Mar 21, 2026

Summary

This PR refactors the external identity schema by renaming provider_id to external_account_id and consolidating OAuth credentials directly into the ExternalIdentity model.

Changes

Database Schema

  • Renamed providers table to external_identities
  • Renamed provider_id column to external_account_id across all modules
  • Removed provider_tokens table (now consolidated into credentials JSON column)
  • Added AccessToken model deletion (credentials now stored inline)
  • Added new migration: 2026_03_21_000001_migrate_providers_to_external_identities.php

New Enums

  • CredentialsType: OAuth2, ApiKey, etc.
  • IdentityType: External, System, Service, etc.

New Components

  • ClientAccessManager: Data class for storing encrypted OAuth credentials
  • AsCredentials: Cast for automatic encryption/decryption of credentials

Updated Modules

  • activity: Message/Voice models now use external_identity_id
  • bot-discord: All events and commands updated to use new column name
  • community: Meeting and Feedback endpoints updated
  • gamification: Character badge/bonus tests updated

Breaking Changes

  • provider_id column renamed to external_account_id
  • AccessToken model removed (use ExternalIdentity::$credentials instead)
  • providers table renamed to external_identities

Migration Required

Run the migration to update existing data:

php artisan migrate

Test Status

All tests have been updated and should pass with the new schema.

Summary by CodeRabbit

  • New Features

    • Improved external account linking with encrypted credential management, connection timestamps, and preserved account metadata (username, email).
  • Bug Fixes

    • Unified request and form fields to consistently use external account identifiers across UI and APIs.
  • Database Migrations

    • Migration to convert provider records into external identities with automatic credential backfill and relationship updates.
  • Refactor

    • Reworked identity handling and DTOs to centralize external identity resolution and storage.

Copy link
Collaborator

@Clintonrocha98 Clintonrocha98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@danielhe4rt danielhe4rt merged commit 6f151f3 into 4.x Mar 21, 2026
5 checks passed
@danielhe4rt danielhe4rt deleted the refactor/external-identity-schema branch March 21, 2026 19:13
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 36928d78-b2a7-4d71-a674-46ddee02b657

📥 Commits

Reviewing files that changed from the base of the PR and between 23c6582 and 4d1f132.

📒 Files selected for processing (1)
  • app/Console/Commands/AuditMorphColumns.php

📝 Walkthrough

Walkthrough

This PR replaces the legacy provider_id identifier with external_account_id across models, DTOs, requests, forms, actions, and tests. It adds a migration that transforms providers/provider_tokens into external_identities, embeds encrypted credentials into a new credentials column, and renames dependent FK columns to external_identity_id. New types and utilities were added (ClientAccessManager, AsCredentials cast, CredentialsType and IdentityType enums), soft deletes were enabled on ExternalIdentity, and the AccessToken model and factory were removed.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.61% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main refactoring work: renaming provider_id to external_account_id and restructuring the database schema. It directly corresponds to the extensive changes throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

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.

3 participants