Mediabibliotheek: module Media met eigen tabellen en geverifieerde kopie van de Hero-foto's (fase 1 van de migratie, standaard uit)
Continuous Integration / config-sls (pull_request) Successful in 10s
Continuous Integration / config-asf (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 20s
Continuous Integration / compile-sites (pull_request) Canceled after 0s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 27s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 54s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:38:40 +01:00
co-authored by Claude Sonnet 5.5
parent fc9417f752
commit 150c156fd7
25 changed files with 1304 additions and 8 deletions
@@ -61,3 +61,5 @@ Kept while Bryan is away (2026-11-17): no questions to him, a most probable assu
- **Confirmed by Bryan "as designed"**: 1, 2, 5, 6, 9, 11, 14, 15, 16, 19, 20, 26, 27, 28.
- **Still assumptions** (not put to him separately): 17 (language), 18 (what phase A contained, now overtaken), 22 (selectability), 23 (performance), 24 (ASF data), 25 (use definitions); and the older rows 18 to 25 above. Assumptions 29 to 32 follow from his decisions.
- Assumption 12 now reads: there IS a trash (decision 12), the earlier "no trash in phase A" no longer applies. Assumption 10: deleting a used photo is possible after a second confirmation (built). Assumption 21: the original file name is stored from now on (built).
| 33 | **Where the copy runs and what it copies** (built 2026-11-17). | A new module `Modules.Media` owns the tables (`MediaAssets`, `MediaUses`); modules offer their data through `IMediaMigrationSource` so the library module does not depend on the Hero. The copy is a verified mirror in one transaction behind `Media:Library:CopyOnStartup` (default false). The use of a hero slide carries both crops (`wide`, `tall`) of its photo as JSON; its set hash is the photo's current set hash. | A copy job triggered from the admin instead of start-up: easier to time, needs an endpoint and a button. | `Modules.Media/Services/MediaLibraryCopier.cs`, `HeroMediaMigrationSource` |
| 34 | **Naming**: entity `MediaAssetUse` (table `MediaUses`), because `MediaUse` already names the read model in Core. | As built. | Rename the table or the record: a small migration. | `Modules.Media/Data` |
@@ -64,10 +64,26 @@ The migration job compares and **aborts** (rolls its transaction back) on any di
3. Back-up first (above), on the test host too.
4. Deploy with the setting **off**, check the verification result in the log, then switch it on, then the smoke test (hero markers, `/theme-init.js`, a sample of media addresses), then Bryan checks the admin.
## What is built first (next step, when this plan is accepted)
## Status (2026-11-17): phase 1 (expand) is built, behind a setting that is OFF
1. A new module `SlpModularCms.Modules.Media` with its own `DbContext`, the tables `MediaAssets` and `MediaUses` and an additive EF migration (no existing table touched), with tests.
2. The copy-and-verify job (idempotent, safe to run twice) behind a setting; unit and in-memory tests, and a test against MariaDB.
3. The library reading from the new tables behind `Media:Library:ReadFromLibrary` (default off).
Built on `feature/media-library-screen`, not yet deployed anywhere:
Nothing in steps 1 to 3 runs without the setting, so a deploy of that code alone changes no data except the new, empty tables.
- New module `SlpModularCms.Modules.Media` (own `MediaDbContext`, tables `MediaAssets` and `MediaUses`, additive migration `InitialCreate`; no existing table is touched). It is referenced by the three hosts, so a deploy of this code creates the two empty tables at start-up and nothing else.
- `IMediaMigrationSource` (Core) and `HeroMediaMigrationSource` (Hero, read-only): the hero's photos (also those in the trash) and slides with their own ids, hashes and set hashes.
- `MediaLibraryCopier`: copies and **verifies** (counts, ids, hash, key, size, set hash) in one transaction; any difference or error rolls the whole copy back and nothing is left. It MIRRORS the source, so running it again gives the same result; rows of other modules are not touched.
- The copy runs only when `Media__Library__CopyOnStartup=true` (default **false**) and a failure is logged, never fatal.
- Tested in memory and against a real MariaDB (migration, copy twice, rollback on a failing copy).
Nothing reads from the new tables yet (phase 2, the switch, is not built). The library screen still reads the hero through the usage provider.
### Roll-out on TEST (needs SLS-Main to be told first)
1. Back-up (database dump and media listing) as above.
2. Deploy the branch with `Media__Library__CopyOnStartup` unset: the two empty tables appear; check the log for the Media migration.
3. Set `Media__Library__CopyOnStartup=true` and restart: the log says `Media library copy verified: N photos and M uses from hero` (or the error and the rollback).
4. Rollback at any point: set it back to false (the tables stay, unused) or drop `MediaUses` and `MediaAssets`.
5. Never on production.
### Still to build (phases 2 and 3)
The switch (`Media:Library:ReadFromLibrary`, dual write of new uploads, library reading from the new tables) and the contract phase. They need Bryan's acceptance of the copy on test first.