Skip to content

Many-to-many movie sharing - #32

Merged
Nottezz merged 7 commits into
mainfrom
many-to-many
Aug 31, 2026
Merged

Nottezz merged 7 commits into
mainfrom
many-to-many

Conversation

@Nottezz

@Nottezz Nottezz commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Implement many-to-many movie sharing: users can join/leave published movies owned by others
  • Add JOIN /movies/{slug}/join and DELETE /movies/{slug}/join endpoints
  • Fix only_mine filter to show only created movies (not joined)
  • Fix Dockerfile: remove invalid COPY ../config.default.yaml outside build context
  • Fix SQLite FK enforcement in tests and stale user references after cascade delete

Test plan

  • only_mine=False — shows all published movies + own unpublished
  • only_mine=True — shows only movies created by the current user
  • Join a published movie → appears in the list with is_joined=true
  • Owner cannot join their own movie
  • Leave a joined movie
  • Backend Docker image builds successfully

🤖 Generated with Claude Code

Nottezz and others added 7 commits August 31, 2026 00:25
- 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>
…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
config.default.yaml is provided at runtime via volume mount at /config.default.yaml,
matching ROOT_DIR expected by Settings. The COPY was unreachable (outside build context)
and also targeted the wrong path (/app/ vs /).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmtbBBZ9em68FUGqwvpiu7
only_mine=True now filters strictly by creator (Movie.user_id),
joined movies appear only in the all-movies view (only_mine=False).

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

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Nottezz
Nottezz merged commit 900c34c into main Aug 31, 2026
5 checks passed
@Nottezz
Nottezz deleted the many-to-many branch August 31, 2026 17:28
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