Fase 3b: de Hero bewaart zijn foto's in de bibliotheektabel (schakelaar uit), HeroImages blijft een kopie, controle bij het opstarten, FK-migratie met Down
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,3 +81,4 @@ Kept while Bryan is away (2026-11-17): no questions to him, a most probable assu
|
||||
| 50 | **Step C reads the library screen's data from the library tables, not the hero admin** (2026-11-17). | The read switch (`off`/`compare`/`on`) changes where the library screen gets photos, trash and uses; the hero's admin and public endpoints keep their own tables because they need the variants, which move in phase 3. Thumbnails come from the hero. `compare` only logs and reports (`GET media-library/read-check`); `on` falls back to the hero's tables when the library cannot be read. | Serve the hero admin from the library too: needs the variants (and cut sets) in the library tables first. | `HeroMediaUsageProvider`, `IMediaLibraryReader`, `MediaLibraryReader`, `MediaReadComparer` |
|
||||
| 51 | **"Controle bibliotheek" panel in the library screen** (SLS-Main for Bryan, 2026-11-17). | A small panel under the storage meter, for administrators (the whole screen is admin only), asks `GET media-library/read-check` only when its button is clicked and says in plain words (nl/en) whether the library tables match each module or lists the differences, plus the state of the three switches (copy, write-through, reading off/compare/on; the response now carries `copyOnStartup` and `dualWrite`). It changes nothing. Always shown, not only on test. | Show it only when the read switch is not off: Bryan could then not check before switching. | `LibraryCheck.tsx`, `MediaLibraryController.ReadCheck`, `IMediaLibrarySwitchState` |
|
||||
| 52 | **Phase 3a: the library tables hold what the hero needs to publish** (2026-11-18). | Additive migration `AddHeroPhotoColumns` of the Media module: `MediaAssets.SetHash`, `MediaAssets.Variants` (the module's own JSON), the wide/tall overrides of the photo's crop, and `MediaUses.Variants`. The copy, the write-through and the verification fill and compare them; the read check shows a difference in them. Nothing reads them to publish yet (that is 3b). | Store the variants relationally: more tables for no gain while only the hero publishes from here. | `MediaEntities`, `MediaLibraryCopier`, `HeroMediaMigrationSource` |
|
||||
| 53 | **Phase 3b maps the hero's photos onto the library table, behind a switch, with HeroImages kept as a copy** (2026-11-18). | `Media__Library__HeroPhotosInLibrary` (default off, test only via the workflow input `media_library_hero_photos`). On: the hero's photo entity is the library's `MediaAssets` rows of module `hero`; `HeroImages` is mirrored after every change so the switch can go back; the application refuses to start if the library lacks a photo or its set/variants; the foreign key slide -> `HeroImages` is dropped by a reversible Hero migration. No data is deleted in 3b; dropping `HeroImages` is step 3c. | Move the data in one go and drop the old table at once: cannot be switched back. | `HeroDbContext.ConfigureStorage`, `HeroLegacyImageMirror`, `HeroPhotoStorageGuard`, migration `DropSlideImageForeignKey` |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Phase 3: the library becomes the truth, the old Hero tables and the switches go
|
||||
|
||||
Status: plan only (2026-11-17). **Nothing in this plan is built or run.** Rules from Bryan, relayed by SLS-Main: build it only after phase 2 is verified on test; dropping the old tables only on TEST, with a back-up and rollback plan and a notice to SLS-Main first; never on production without a separate go from Bryan; no PR for the phase-2/3 branch before #22 is merged.
|
||||
Status (2026-11-18): steps 3a and 3b are BUILT on `feature/media-library-phase2` (3b behind a switch that is off by default); step 3c (dropping the old table and the switches) is NOT built and NOT run. Rules from Bryan, relayed by SLS-Main: build it only after phase 2 is verified on test; dropping the old tables only on TEST, with a back-up and rollback plan and a notice to SLS-Main first; never on production without a separate go from Bryan; no PR for the phase-2/3 branch before #22 is merged.
|
||||
|
||||
## Where phase 2 leaves us
|
||||
|
||||
@@ -41,3 +41,22 @@ Public addresses (`/media/hero/<setHash>/...`), ids and hashes stay as they are
|
||||
|
||||
- 3c is a separate release after a quiet period on test (assumption: at least a week), not part of the first rollout of phase 2.
|
||||
- The clean-up job of the Hero (`HeroMediaCleanup`) moves to the library in 3b, so other modules can use the same retention rules.
|
||||
|
||||
## As built: 3a and 3b (2026-11-18)
|
||||
|
||||
**3a, expand (Media migration `AddHeroPhotoColumns`, additive):** `MediaAssets` gets `SetHash`, `Variants` (the hero's own JSON), `WideFocusX/Y/Zoom`, `TallFocusX/Y/Zoom`; `MediaUses` gets `Variants`. The verified copy, the write-through and the read check fill and compare them (a difference in the set or variants shows in the library check).
|
||||
|
||||
**3b, the switch (Hero migration `DropSlideImageForeignKey` + switch `Media__Library__HeroPhotosInLibrary`, default off):**
|
||||
- The migration drops only the foreign key `FK_HeroSlides_HeroImages_ImageId` (a slide may point at a photo that is only in `MediaAssets`). It has a `Down` that puts it back. The model snapshot is deliberately unchanged. The service layer already checks that a photo exists and is not removed while a slide uses it.
|
||||
- With the switch **on**, the Hero's photo entity is mapped to the library table: rows of `MediaAssets` with module `hero` (columns `DefaultFocusX/Y/Zoom`, a `Module` column set to `hero`, a query filter on it). Everything else in the hero (services, renderer, public mapping, clean-up) is unchanged and runs on those rows. The library owns that table and its migrations; the hero's context excludes it from its own.
|
||||
- `HeroImages` stays a **complete copy** while the switch is on (`HeroLegacyImageMirror` after every saved change), so switching back loses nothing.
|
||||
- **Start-up guard:** with the switch on, the application refuses to start (clear message in the log) unless the library holds every photo of `HeroImages` with the same hash, set and variants. So the order is fixed: copy first, library check, then the switch.
|
||||
- Public addresses, ids and hashes are unchanged; the golden files are untouched.
|
||||
|
||||
**Order on test (each step a deploy, SLS-Main tells Bryan):**
|
||||
1. Deploy with `media_library_copy=on` (and `media_library_dual_write=on`): the migrations run and the copy fills the new columns for the existing photos. Open "Controle bibliotheek": it must say that the library matches the hero (it now also compares set and variants).
|
||||
2. Deploy with `media_library_hero_photos=on`. If the guard refuses to start, the log says why; set the switch back to off.
|
||||
3. Check the hero admin (upload, crop a slide, save, trash and restore) and the public site; the library check still matches.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user