Skip to content

Conversation

@lukinovec
Copy link
Contributor

This PR adds listeners for handling cleanup of pivot records/mappings

  • when any synced resource got deleted (previously, the cleanup was only happening on SyncMaster/central resource deletion) - on SyncedResourceDeleted (fired when any synced resource got deleted), DeleteResourceMapping
  • when a tenant gets deleted - on TenantDeleted, DeleteAllTenantMappings (until now, the pivot records were only getting deleted when the tenant key column had a constraint, and the constraint had onDelete('cascade') -- db-level)

This PR also improves some resource syncing implementation details, for example, the ResourceSyncing trait now uses static::deleted() instead of static::deleting(), which is safer. The SyncedResourceDeleted event with the DeleteResourceMapping listener also lets us separate the resource x pivot record deletion concerns, and improve the performance (e.g. the mass delete of pivot records when SyncMaster's deleted instead of a for loop where we were deleting the pivot records one by one).

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.56%. Comparing base (8bdacf5) to head (728d2db).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1411      +/-   ##
============================================
+ Coverage     85.46%   85.56%   +0.09%     
- Complexity     1133     1140       +7     
============================================
  Files           181      184       +3     
  Lines          3323     3345      +22     
============================================
+ Hits           2840     2862      +22     
  Misses          483      483              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lukinovec lukinovec marked this pull request as ready for review November 5, 2025 16:32
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.

2 participants