Fase 3c (code, nog niet uitgerold): foto's altijd in de bibliotheektabel, HeroImages-migratie met controle, schakelaars en hulpmiddelen weg

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 00:21:58 +01:00
co-authored by Claude Sonnet 5.5
parent 7246efccc1
commit d9e57425c2
52 changed files with 792 additions and 2537 deletions
@@ -60,3 +60,23 @@ Public addresses (`/media/hero/<setHash>/...`), ids and hashes stay as they are
4. Rollback at any time: `media_library_hero_photos=off` (the application reads `HeroImages` again, a complete copy). To undo the foreign-key migration too: the `Down` of `DropSlideImageForeignKey`. Last resort: the restore point of the test sites.
**Step 3c (not built):** drop `HeroImages` and the legacy mirror, remove the three media switches and the copier, make the library table the only home. Needs: Bryan's verification of 3b on test, a notice to SLS-Main with the exact migration, a fresh restore point; test only.
## Step 3c as built (2026-11-18) - on its own branch, NOT deployed
Branch `feature/media-library-phase3c` (from `feature/media-library-phase2`). It is a separate branch on purpose: dispatching `phase2` can never carry the destructive migration by accident. It is code, docs and tests only; nothing has been run on a test host.
**What it removes**
- The three migration switches and everything behind them: `Media__Library__CopyOnStartup` and the copier, `DualWrite` and the write-through (`IMediaLibrarySync`), `ReadFromLibrary` and the reader/compare mode (`IMediaLibraryReader`), `HeroPhotosInLibrary` and the legacy mirror, the start-up guard and the storage switch (`HeroStorage`, model cache key).
- The "Controle bibliotheek" panel, the `read-check` endpoint and the migration source (`IMediaMigrationSource`, `HeroMediaMigrationSource`). Bryan: keep the panel until 3b is verified on test, then remove it together with the other migration aids (so: in this step).
- The four workflow inputs (`media_library_copy`, `_dual_write`, `_read`, `_hero_photos`) and their deploy steps.
**What it makes permanent:** the hero's photos are rows of the library's `MediaAssets` (module `hero`, filter and `Module` column in the hero's model; the table and its migrations belong to the Media module). `MediaUses` is no longer written or read (it stays in the database, empty of meaning; dropping it is a later clean-up).
**The destructive migration:** Hero `DropHeroImagesTable` (`DROP TABLE HeroImages`). Protected twice:
1. `HeroImagesDropGuard` runs before the migrations at start-up: when that migration is pending and `HeroImages` holds rows, it throws (the application does not start, nothing is dropped) unless every row is in `MediaAssets` (module hero) with the same hash, set and variants, or when `MediaAssets` does not exist. A new database (nothing in `HeroImages`) passes.
2. The restore point of the test sites, taken right before the deploy.
`Down` brings back the EMPTY table (data comes from the restore point). Tested on MariaDB: refused with a missing photo, refused with a different set, dropped when the library holds everything, Down recreates the empty table.
**Order on test (needs Bryan's OK on 3b and a notice to SLS-Main with this exact migration):** (1) 3b verified: copy done, library check matches, `HeroPhotosInLibrary=on` verified by Bryan and live for a quiet period; (2) fresh restore point (Pi-Main script); (3) deploy `feature/media-library-phase3c` (the switches no longer exist; the variable `Media__Library__HeroPhotosInLibrary` in `shared/env` can stay, it is ignored); (4) check the hero admin, the public site and the library screen. Rollback: restore the restore point and deploy the previous release; `Down` only gives the empty table.
Not tested here: the deploy itself, the media directory on the Pi, the production database (never).