Wire up pre-drain in Projects::DestroyService

Summary

Add the batched pre-drain call to Projects::DestroyService so child tables are deleted in committed batches before project.destroy!. No custom strategy hooks yet. All tables use raw SQL DELETE.

This proves the pattern works end-to-end. Strategy hooks for tables with side effects come in #619136.

Requirements

  1. Call pre-drain before project.destroy!. Invoke BatchedPreDrain for the project's CASCADE FK children.
  2. Re-enqueue on budget exhaustion. If the pre-drain returns :over_budget, re-enqueue the worker and return. The project stays pending_delete. The next run picks up where it left off.
  3. Destroy the project. Once the pre-drain finishes, call project.destroy!. It now cascades only a small remainder, or nothing.
  4. Disable QueryLimiting for the worker if not already disabled.

Out of scope

Per-table strategy hooks for side effects (uploads, search index, container registry). Those are handled in #619136.

Specs

  • Pre-drain runs before destroy!
  • Worker re-enqueues on :over_budget
  • destroy! succeeds with minimal cascade
  • Partial drain + crash + re-run works correctly (idempotent)

Dependencies

Depends on the generic batched pre-drain helper (#619116).

References

Edited by 🤖 GitLab Bot 🤖