fix: subscription tier sync on admin override (#58) #61

Merged
egullickson merged 2 commits from issue-58-subscription-tier-sync into main 2026-01-24 16:55:37 +00:00
Owner

Summary

  • Admin tier changes now update both subscriptions.tier and user_profiles.subscription_tier atomically
  • Fixed bug in grace-period job using wrong column name for user_profiles sync

Changes

  1. SubscriptionsService: Added adminOverrideTier() method with transaction wrapping
  2. SubscriptionsRepository: Added updateTierByUserId() and createForAdminOverride() methods
  3. UsersController: Changed to use subscriptionsService.adminOverrideTier() instead of userProfileService.updateSubscriptionTier()
  4. grace-period.job.ts: Fixed WHERE user_id to WHERE auth0_sub

Test Plan

  • Admin changes user tier via UI
  • Verify subscriptions.tier updated
  • Verify user_profiles.subscription_tier updated
  • Verify Settings page shows correct tier
  • Desktop viewport validation
  • Mobile viewport validation

Follow-up Issues

  • #59 - Send notifications when subscription tier changes
  • #60 - Prompt vehicle selection on login after auto-downgrade

Fixes #58

🤖 Generated with Claude Code

## Summary - Admin tier changes now update both `subscriptions.tier` and `user_profiles.subscription_tier` atomically - Fixed bug in grace-period job using wrong column name for user_profiles sync ## Changes 1. **SubscriptionsService**: Added `adminOverrideTier()` method with transaction wrapping 2. **SubscriptionsRepository**: Added `updateTierByUserId()` and `createForAdminOverride()` methods 3. **UsersController**: Changed to use `subscriptionsService.adminOverrideTier()` instead of `userProfileService.updateSubscriptionTier()` 4. **grace-period.job.ts**: Fixed `WHERE user_id` to `WHERE auth0_sub` ## Test Plan - [ ] Admin changes user tier via UI - [ ] Verify `subscriptions.tier` updated - [ ] Verify `user_profiles.subscription_tier` updated - [ ] Verify Settings page shows correct tier - [ ] Desktop viewport validation - [ ] Mobile viewport validation ## Follow-up Issues - #59 - Send notifications when subscription tier changes - #60 - Prompt vehicle selection on login after auto-downgrade Fixes #58 🤖 Generated with [Claude Code](https://claude.com/claude-code)
egullickson added 2 commits 2026-01-19 15:59:22 +00:00
Add adminOverrideTier() method to SubscriptionsService that atomically
updates both subscriptions.tier and user_profiles.subscription_tier
using database transactions.

Changes:
- SubscriptionsRepository: Add updateTierByUserId() and
  createForAdminOverride() methods with transaction support
- SubscriptionsService: Add adminOverrideTier() method with transaction
  wrapping for atomic dual-table updates
- UsersController: Replace userProfileService.updateSubscriptionTier()
  with subscriptionsService.adminOverrideTier()

This ensures admin tier changes properly sync to both database tables,
fixing the Settings page "Current Plan" display mismatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix: correct user_profiles column name in grace-period job (refs #58)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m9s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 29s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
8c86d8d492
The grace-period job was using 'user_id' to query user_profiles table,
but the correct column name is 'auth0_sub'. This would cause the tier
sync to fail during grace period auto-downgrade.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
egullickson merged commit 7c39d2f042 into main 2026-01-24 16:55:37 +00:00
egullickson deleted branch issue-58-subscription-tier-sync 2026-01-24 16:55:38 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: egullickson/motovaultpro#61