Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors the relations between photos and albums by removing the direct album_id association and replacing it with a many-to-many relationship. Key changes include updating queries in several actions (e.g. Statistics, RSS, DuplicateFinder), splitting the responsibilities previously handled by SetParentAndOwnership into SetParent and SetOwnership, and modifying deletion and merging logic to work with the new PA::PHOTO_ALBUM table.
Reviewed Changes
Copilot reviewed 72 out of 72 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/Actions/Statistics/Spaces.php | Updated join queries to use the new many-to-many relationship |
| app/Actions/Search/PhotoSearch.php | Replaced the 'album' relation with 'albums' for photo queries |
| app/Actions/RSS/Generate.php | Refactored feed item creation to match updated data handling |
| app/Actions/Photo/Pipes/Shared/SetParent.php | Added new file to handle linking photos to albums via the relation |
| app/Actions/Photo/Pipes/Shared/SetOwnership.php | Added new file to separately set photo ownership |
| app/Actions/Photo/Pipes/Shared/NotifyAlbums.php | Adjusted album notification logic using DB count instead of album_id check |
| app/Actions/Photo/Pipes/Init/FindLivePartner.php | Updated to use many-to-many join conditions for live partner lookup |
| app/Actions/Photo/MoveOrDuplicate.php | Implements new linking logic for moving or duplicating photos |
| app/Actions/Photo/DuplicateFinder.php | Updated duplicate finding queries to leverage the new relation |
| app/Actions/Photo/Delete.php | Refactored deletion logic, adding argument validation and relation cleanup |
| app/Actions/Photo/Create.php | Updated photo creation pipelines to use SetParent and SetOwnership instead of the removed SetParentAndOwnership |
| app/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.php | Modified integrity check queries to use the new albums relationship |
| app/Actions/Albums/PositionData.php | Adjusted photo position data queries and resource instantiation |
| app/Actions/Album/PositionData.php | Changed relation type to BelongsToMany and updated resource parameters |
| app/Actions/Album/Merge.php | Refactored merging logic to use the many-to-many table without duplicates |
| app/Actions/Album/Delete.php | Updated album deletion logic to delegate photo cleanup to PhotoDelete with revised arguments |
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
a745953 to
9e97597
Compare
cb3cf0b to
9ba1a70
Compare
9e97597 to
659305c
Compare
9ba1a70 to
916e593
Compare
659305c to
877f658
Compare
916e593 to
bcca8f7
Compare
a921deb to
ecc738c
Compare
6cbc89d to
6e39bb0
Compare
6e39bb0 to
b68cb45
Compare
Closes #1095
Drops the album_id attribute from the 'photos` table and create a relation table to allow a photo to be related to multiple albums.
This pull request introduces significant changes to the handling of photo and album operations, focusing on improving database integrity, optimizing queries, and enhancing maintainability. Key updates include refactoring the
DeleteandMergeactions for albums, modifying thePositionDatalogic, and restructuring photo deletion to better handle relationships and constraints.Album and Photo Deletion Refactor:
app/Actions/Album/Delete.php. Simplified the deletion process by delegating photo and album relationship handling to thePhotoDeleteclass, which now accepts an optionalfrom_idparameter for improved flexibility. [1] [2] [3]app/Actions/Photo/Delete.phpto ensure arguments are consistent and to collect photos based on their album relationships. This includes methods likecollectUnsortedPhotos,collectPhotosInAlbums, andcollectPhotosInAlbumsByAlbumID. [1] [2]Album Merging Enhancements:
Mergeaction inapp/Actions/Album/Merge.phpto handle many-to-many relationships between photos and albums using thePA::PHOTO_ALBUMtable. This avoids duplicate entries by deleting existing links before inserting new ones.Position Data Updates:
PositionDatalogic inapp/Actions/Album/PositionData.phpandapp/Actions/Albums/PositionData.phpto use thealbumsrelationship instead ofalbum. This aligns with the shift to many-to-many relationships. [1] [2]PositionDataResourceconstructor calls to reflect these changes. [1] [2]Database Integrity and Diagnostics:
DBIntegrityCheckpipe inapp/Actions/Diagnostics/Pipes/Checks/DBIntegrityCheck.phpto use thealbumsrelationship when checking for photos without originals. This ensures compatibility with the new data model.Miscellaneous Improvements:
app/Actions/Photo/Create.phpby splittingSetParentAndOwnershipintoSetParentandSetOwnership. This improves modularity and clarity. [1] [2] [3]