Skip to content

Implement many-to-many movie sharing - #31

Merged
Nottezz merged 4 commits into
mainfrom
many-to-many
Aug 30, 2026
Merged

Nottezz merged 4 commits into
mainfrom
many-to-many

Conversation

@Nottezz

@Nottezz Nottezz commented Aug 30, 2026

Copy link
Copy Markdown
Owner
  • Add UserMovie join table with per-user watched/note/rating state
  • Migrate watched/note/rating fields from Movie to UserMovie
  • Add POST/DELETE /movies/{slug}/join endpoints
  • Update MovieRead schema with is_joined and joined_by fields
  • Update GET /movies/ to include creator's own unpublished movies
  • Add join/leave actions and joined-by list on frontend
  • Restrict title/description/year edits to owner only
  • Remove redundant get_or_create_user_movie wrapper
  • Remove unnecessary DB queries in delete_movie (204 response)
  • Fix dead movie-is-None guard in update_movie_metadata
  • Add many-to-many integration tests

- Add UserMovie join table with per-user watched/note/rating state
- Migrate watched/note/rating fields from Movie to UserMovie
- Add POST/DELETE /movies/{slug}/join endpoints
- Update MovieRead schema with is_joined and joined_by fields
- Update GET /movies/ to include creator's own unpublished movies
- Add join/leave actions and joined-by list on frontend
- Restrict title/description/year edits to owner only
- Remove redundant get_or_create_user_movie wrapper
- Remove unnecessary DB queries in delete_movie (204 response)
- Fix dead movie-is-None guard in update_movie_metadata
- Add many-to-many integration tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Nottezz Nottezz self-assigned this Aug 30, 2026
Nottezz and others added 3 commits August 31, 2026 00:40
…tract test

- Add cascade="all, delete-orphan", passive_deletes=True to User.joined_movies
  so SQLAlchemy correctly deletes UserMovie rows (NOT NULL FK) on user delete
  in test teardown, preventing UserAlreadyExists in subsequent tests
- Add is_joined and joined_by to expected_fields in test_movie_read_fields_contract
  to match new MovieRead schema fields added in this PR

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without cascade="all, delete-orphan" on User.movies, SQLAlchemy tried to
SET NULL on movie.user_id (NOT NULL) when deleting a user in test teardown.
This caused an IntegrityError, the user was never deleted, and subsequent
tests failed with UserAlreadyExists.

Adding cascade="all, delete-orphan" causes SQLAlchemy to delete the user''s
movies first, avoiding the FK violation. UserMovies for those movies are
then handled by DB-level ON DELETE CASCADE (already defined on movie_id FK).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Guard against None user in joined_by list after cascade delete
- Add confirm_deleted_rows=False to UserMovie mapper to avoid StaleDataError
- Enable PRAGMA foreign_keys=ON for SQLite test engine

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmtbBBZ9em68FUGqwvpiu7
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.51020% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/backlog_app/api/view/movie_view.py 21.21% 26 Missing ⚠️
backend/backlog_app/api/crud.py 88.75% 9 Missing ⚠️
backend/backlog_app/tasks/movie_task.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Nottezz
Nottezz merged commit 64e2bcc into main Aug 30, 2026
5 checks passed
@Nottezz
Nottezz deleted the many-to-many branch August 30, 2026 22:35
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.

1 participant