Skip to content

Fix ownership cascades during account deletion#210

Merged
chriscarrollsmith merged 1 commit into
mainfrom
209-align-db-cascades-with-accountuser-orphan-relationships
Jun 30, 2026
Merged

Fix ownership cascades during account deletion#210
chriscarrollsmith merged 1 commit into
mainfrom
209-align-db-cascades-with-accountuser-orphan-relationships

Conversation

@chriscarrollsmith

Copy link
Copy Markdown
Contributor

Summary

  • Align ownership-style child foreign keys with ORM delete-orphan behavior using ON DELETE CASCADE metadata and an idempotent migration script.
  • Delete organizations that would become userless during account deletion, while preserving shared organizations and their owned resources.
  • Add regression coverage for sole-user and shared-organization deletion behavior plus direct SQL cascade behavior.

Closes #209

Test plan

  • uv run pytest tests/routers/core/test_account.py tests/utils/test_models.py
  • uv run python -m migrations.align_ownership_cascades .env
  • uv run ty check .
  • uv run ruff check routers/core/account.py utils/core/models.py utils/app/models.py migrations/align_ownership_cascades.py tests/routers/core/test_account.py tests/utils/test_models.py

@chriscarrollsmith chriscarrollsmith linked an issue Jun 30, 2026 that may be closed by this pull request
@chriscarrollsmith
chriscarrollsmith merged commit 7c79c5b into main Jun 30, 2026
2 checks passed
@chriscarrollsmith
chriscarrollsmith deleted the 209-align-db-cascades-with-accountuser-orphan-relationships branch June 30, 2026 23:39
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.

Align DB cascades with account/user orphan relationships

1 participant