This commit includes a major refactoring of the GORM many-to-many relationships to use explicit join tables, improving stability and compatibility with GORM's features.
It also implements a large number of previously unimplemented GraphQL mutations for core entities like Collections, Comments, Likes, and Bookmarks.
Key changes:
- Refactored polymorphic many-to-many relationships for Copyright and Monetization to use standard many-to-many with explicit join tables.
- Implemented GraphQL mutations for Collection, Comment, Like, and Bookmark entities, including input validation and authorization checks.
- Added comprehensive integration tests for all new features and refactored code.
- Refactored the GraphQL integration test suite to be type-safe, using generics for response handling as requested.
- Updated repository interfaces and implementations to support the new data model.
- Updated the TODO.md file to reflect the completed work.
The main changes are:
- Refactored the `Copyright` and `Monetization` relationships to use explicit join tables for each owning model, as per the "Option A" strategy. This fixes the GORM migration issues related to polymorphic many-to-many relationships.
- Created new join table structs (e.g., `WorkCopyright`, `AuthorCopyright`, `WorkMonetization`, etc.).
- Updated the domain models to use standard `gorm:"many2many"` tags with the new join tables.
- Refactored the `CopyrightRepository` and `MonetizationRepository` to use the new association-based logic.
- Updated the application services (`CopyrightCommands`, `CopyrightQueries`, `MonetizationCommands`, `MonetizationQueries`) to use the new repository methods.
- Consolidated all repository interfaces into a single `internal/domain/interfaces.go` file for better code organization.
- Added extensive integration tests for the new repository and application layer logic for `Copyrights` and `Monetizations`.
- Fixed the deletion logic for `WorkRepository` to correctly handle cascading deletes with SQLite.
- Updated the `TODO.md` file to mark the "Stabilize non-linguistics tests and interfaces" task as complete.
This commit includes the following changes:
- Refactored all data repositories in `internal/data/sql/` to use a consistent `sql` package and to align with the new `domain` models.
- Fixed the GraphQL structure by moving the server creation logic from `internal/app` to `cmd/api`, which resolved an import cycle.
- Corrected numerous incorrect import paths for packages like `graph`, `linguistics`, `syncjob`, and the legacy `models` package.
- Resolved several package and function redeclaration errors.
- Removed legacy migration code.