Skip to content

feat: add soft delete support for users, projects, and organizations#214

Open
rishab11250 wants to merge 1 commit into
nensii21:mainfrom
rishab11250:feat/soft-delete-support
Open

feat: add soft delete support for users, projects, and organizations#214
rishab11250 wants to merge 1 commit into
nensii21:mainfrom
rishab11250:feat/soft-delete-support

Conversation

@rishab11250

Copy link
Copy Markdown

Pull Request

Summary

Add soft delete support for Users, Projects, and Organizations. Instead of permanently deleting records, they are now marked with a deleted_at timestamp and hidden from all normal queries. Admins can restore or permanently delete them.


Related Issue

Closes #198


Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring
  • UI/UX enhancement
  • Tests
  • Other

Changes Made

  • Models — Added deleted_at (datetime) and deleted_by_id (FK → users.id) columns with deleted_by relationships to User, Project, and Organization.
  • Schemas — Created missing ProjectResponse and OrganizationResponse schemas in app/schemas/project.py and app/schemas/organization.py. Added deleted_at / deleted_by_id to UserResponse.
  • Services — All get_*, list_*, get_by_*, search_* methods now filter out soft-deleted records. delete_* methods replaced with soft_delete_* (sets timestamp). Added restore_* and hard_delete_* methods.
  • Routers — Added PATCH /{entity}/{id}/restore (owner/superuser) and DELETE /{entity}/{id}/hard (superuser only) endpoints.
  • Migration4b4c96034900_add_soft_delete_columns.py adds all columns with named foreign key constraints.

Testing

  • Tested locally (syntax check on all 13 modified files)
  • Existing tests pass
  • Added new tests
  • UI verified
  • Cross-browser tested (if applicable)

Additional testing notes: No database connection available locally to run migration against live PostgreSQL. Migration is structured following existing patterns with proper upgrade/downgrade paths.


Checklist

  • My code follows the project's coding standards.
  • I have tested my changes locally (syntax-validated all files).
  • I have updated the documentation where necessary.
  • My changes do not introduce new warnings or errors.
  • I have reviewed my own code.
  • This pull request focuses on a single feature or fix.
  • I have linked the related issue.

Additional Notes

Permission model:

Action Who can do it
Soft delete Owner (or self for users)
Restore Owner or superuser
Hard delete (permanent) Superuser only

Branch: feat/soft-delete-support
Commit: 4fe9f36

- Add deleted_at and deleted_by_id columns to User, Project, Organization models
- Create missing project and organization Pydantic schemas
- Convert all hard deletes to soft deletes in services
- Filter out soft-deleted records from all queries
- Add restore and hard-delete endpoints to routers
- Create Alembic migration for new columns
- Permission model: owner soft-deletes, owner/superuser restores, superuser hard-deletes

Closes nensii21#198
@nensii21

nensii21 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

attached videos and screenshots showing what changes have been made also some CI jobs are failing update it.

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.

Add Soft Delete Support

2 participants