Skip to content

fix: data migration indexes#289

Merged
gvieira18 merged 1 commit into
4.xfrom
fix/socorro
May 26, 2026
Merged

fix: data migration indexes#289
gvieira18 merged 1 commit into
4.xfrom
fix/socorro

Conversation

@danielhe4rt
Copy link
Copy Markdown
Contributor

@danielhe4rt danielhe4rt commented May 26, 2026

Description

This PR fixes data migration issues by replacing a problematic tenant ID type conversion migration with a new index restoration migration. Instead of converting tenant_id from bigint to UUID (which proved problematic), the PR takes a more targeted approach by recreating essential tenant-related indexes across 34 tables using concurrent index creation with optimized memory settings.

References

  • Related PR #288: OAuth flow refactor with account merge strategy
  • Related PR #282: Profile module phase 1 with legacy cleanup
  • Related PR #274: Profile module with tenant-scoped user profiles

Changes Summary

File Path Change Description
app-modules/identity/database/migrations/2026_05_26_020000_restore_tenant_id_indexes_and_foreign_keys.php New migration creating 34 tenant-related indexes across critical, medium, and small tables using CREATE INDEX CONCURRENTLY with 1GB maintenance work memory optimization.
database/migrations/2026_05_25_225721_convert_tenant_id_from_bigint_to_uuid.php Removed problematic migration that attempted to convert tenant_id columns from bigint to UUID type across multiple tables.

Contributor Summary

Contributor Lines Added Lines Removed Files Changed
danielhe4rt 100 98 2

Review Change Stack

@danielhe4rt danielhe4rt marked this pull request as ready for review May 26, 2026 02:30
@gvieira18 gvieira18 merged commit 0950786 into 4.x May 26, 2026
9 of 11 checks passed
@gvieira18 gvieira18 deleted the fix/socorro branch May 26, 2026 02:31
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b400a637-3a36-42df-a61e-df416b71dcb3

📥 Commits

Reviewing files that changed from the base of the PR and between 3f7d417 and 1ae78a8.

📒 Files selected for processing (2)
  • app-modules/identity/database/migrations/2026_05_26_020000_restore_tenant_id_indexes_and_foreign_keys.php
  • database/migrations/2026_05_25_225721_convert_tenant_id_from_bigint_to_uuid.php

📝 Walkthrough

Walkthrough

This pull request removes a previous database migration that converted tenants.id from bigint to uuid type and introduces a new migration that restores tenant-related indexes and foreign keys. The new migration file in app-modules/identity/database/migrations/ uses PostgreSQL CREATE INDEX CONCURRENTLY statements to recreate indexes across multiple tables without blocking, temporarily increasing maintenance_work_mem to 1GB for performance during the index creation process. The down() method explicitly lists and drops each created index to allow migration reversal.


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.

gvieira18 pushed a commit that referenced this pull request May 26, 2026
…rovements (#290)

## Summary

- **OAuth error handling**: Gracefully handle token exchange failures
and missing credentials instead of crashing with unhandled exceptions
- **ConnectionHub UX**: Compact layout for profile sidebar, light/dark
theme support, refined disconnect button styling
- **Portal improvements**: Add "Área do Usuário" navbar link, Twitch as
login provider, fix hero avatar metadata key (`name` vs `username` for
legacy/new GitHub records)
- **Provider reconnection**: Clear `disconnected_at` when reconnecting
an existing provider

## Changes

### Identity module
- `OAuthController`: catch `OAuthFlowException` on token exchange,
redirect with error notification
- `AttachProviderToUser`: clear `disconnected_at` on reconnect
- OAuth clients (Discord, GitHub, Twitch): throw `OAuthFlowException` on
missing credentials

### Panel App
- `ConnectionHub`: compact card layout, dark/light theme support,
pill-style disconnect button, timestamp next to title
- `LoginPage`: add Twitch OAuth button
- Profile wrapper: light mode compatible (`bg-white dark:bg-gray-900`)

### Portal
- Navbar: outlined "Área do Usuário" button linking to `/app`
- `HeroSection`: support both `username` (new) and `name` (legacy)
metadata keys for GitHub avatars

## Test plan
- [ ] OAuth login with Discord, GitHub, and Twitch
- [ ] Disconnect/reconnect a provider from profile ConnectionHub
- [ ] Verify ConnectionHub renders correctly in both light and dark mode
- [ ] Portal landing page loads without errors (hero avatars)
- [ ] "Área do Usuário" navbar link navigates to `/app`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Description

This PR enhances OAuth security and user experience across the platform.
It adds comprehensive error handling for OAuth token exchanges,
validates provider credentials at initialization, and resets
disconnected provider states on reconnection. The ConnectionHub UI is
updated with improved light/dark theme support and refined styling,
while the portal gains Twitch OAuth support and fixes GitHub avatar
metadata handling. The identity module prevents unhandled exceptions by
catching OAuth failures with explicit error notifications.

## References

- PR `#288`: [OAuth flow refactor with account merge
strategy](#288) — Related
OAuth improvements
- PR `#272`: [Twitch integration with admin panel, tenant-scoped
EventSub, and subscription
management](#272) — Twitch
integration foundation
- PR `#289`: [Data migration
indexes](#289) — Related
database changes

## Dependencies & Requirements

No new dependencies were added or updated in this PR. All changes
utilize existing framework and module capabilities.

## Contributor Summary

| Contributor | Lines Added | Lines Removed | Files Changed |
|---|---|---|---|
| danielhe4rt | 136 | 45 | 12 |

## Changes Summary

| File Path | Change Description |
|---|---|
| app-modules/identity/src/Auth/Exceptions/OAuthFlowException.php |
Added `tokenExchangeFailed()` factory method for formatted OAuth token
exchange error messages |
| app-modules/identity/src/Auth/Http/Controllers/OAuthController.php |
Enhanced error handling for missing OAuth configurations, denied
callbacks, and token exchange failures with try/catch blocks and
redirects |
| app-modules/identity/src/Auth/Actions/AttachProviderToUser.php | Reset
`disconnected_at` to null on reconnection to mark providers as active
again |
| app-modules/integration-discord/src/OAuth/DiscordOAuthClient.php |
Added validation for `access_token` presence in Discord token response;
throws `OAuthFlowException` on missing token |
|
app-modules/integration-github/src/IntegrationGithubServiceProvider.php
| Added validation for GitHub client credentials with explicit
RuntimeException on missing configuration |
| app-modules/integration-github/src/OAuth/GitHubOAuthClient.php | Added
validation for `access_token` in GitHub token response; throws
`OAuthFlowException` on missing token |
| app-modules/integration-twitch/src/OAuth/TwitchOAuthClient.php | Added
validation for `access_token` in Twitch token response; throws
`OAuthFlowException` on missing token |
| app-modules/panel-app/resources/views/auth/login.blade.php | Added
Twitch OAuth login button alongside Discord and GitHub options |
| app-modules/panel-app/resources/views/pages/profile.blade.php |
Updated profile card styling with rounded backgrounds, rings, and dark
mode variants |
| app-modules/portal/resources/views/components/navbar.blade.php | Added
responsive "Área do Usuário" link and restructured Discord button for
mobile/desktop variants |
| app-modules/portal/src/Livewire/HeroSection.php | Updated avatar
metadata mapping to support both legacy `name` and new `username` keys
for GitHub records |
| resources/views/livewire/connection-hub.blade.php | Refined
ConnectionHub styling for light/dark theme compatibility, updated
disconnect button and permissions section appearance |

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/he4rt/heartdevs.com/pull/290?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

4 participants