Runs health checks on the media library and reports issues.
Performs four checks:
- File existence — verifies every local-disk media file is present on disk (skipped for remote adapters such as S3).
- Broken conversions — verifies that every recorded conversion file exists on disk.
- Orphaned records — detects media records whose parent model no longer
exists in the database (uses
PhxMediaLibrary.ModelRegistry). - Soft-delete backlog — warns when there are trashed records older than 30 days (only when soft-deletes are enabled).
Usage
$ mix phx_media_library.doctor
Options
--skip-files Skip file existence and broken-conversion checks
--skip-orphans Skip orphaned record detection
--fix Permanently delete broken/missing media (with prompt)Examples
# Full health check
$ mix phx_media_library.doctor
# Skip file checks (useful when files are on S3)
$ mix phx_media_library.doctor --skip-files
# Automatically clean up broken media after confirmation
$ mix phx_media_library.doctor --fix