# Media library: rollout to production in one release Status (2026-11-18): built on `feature/media-library-oneshot`, NOT executed, NOT on production. Production only on an explicit go from Bryan. No `release/*` branches. ## What changed compared with the staged plan Master (phases 2 and 3c) has no copier and no switches any more, so production (which still has the hero's photos only in `HeroImages`) could not go straight to it: the drop guard would refuse. The staged road (phase 2 with the copy, then 3b, then 3c) is no longer needed, because the start-up now does the copy itself, once, right before the drop: 1. `HeroModule.UseModule` calls `HeroImagesDropGuard.PrepareAndVerify`. If the migration `DropHeroImagesTable` is pending: 2. the hero's own migrations up to the one before the drop are applied (so `HeroImages` has its final columns); 3. if `HeroImages` holds photos: the library tables are brought to the current schema through `IMediaLibrarySchema` (implemented by the Media module, which runs its migrations; this makes the order in which modules start irrelevant) and the photos are copied into `MediaAssets` (module `hero`): rows that differ are updated, missing rows inserted, nothing is deleted. HeroImages is the truth at that moment. The copy is one transaction; 4. `Verify` (unchanged, strict) compares hash, set hash and variants of every photo; on any difference it throws `ModuleStartupException`; 5. only then `Migrate()` runs the drop. Uses (`MediaUses`) are not copied: after 3c nothing reads them (the library screen asks the modules' providers). **Guard now really stops the application.** `ModuleOrchestrator.UseModules` used to log every module exception and continue, so a refusing guard would have left the application running without the hero's migration (data safe, but a half-state). `ModuleStartupException` is now rethrown, so the host does not start; the log has a Critical line with the reason. ## The steps on production | # | Step | Check | Rollback | |---|---|---|---| | 0 | Fresh restore point of production (database dump; the Pi-Main script) and counts per site: `HeroImages` rows, `HeroSlides`, 10 sample public addresses | Path of the restore point written down | n/a | | 1 | Deploy this release (the one with the one-shot copy). Needs Bryan's go on the exact migration (`DROP TABLE HeroImages` after the copy) | Journal: `Applying migration ..._AddHeroPhotoColumns` (Media), the Hero migrations, `..._DropHeroImagesTable`, no Critical line; `/health` 200; `MediaAssets` has the same number of hero rows as `HeroImages` had; hero admin and public site; the 10 addresses unchanged | Restore point of step 0 + deploy the previous release. `Down` of the drop only recreates an empty table | The restore point is the only way back after the drop. It must be taken immediately before step 1. ## Things to know - Both sites are handled the same way; a site with an empty `HeroImages` just migrates. - If the guard refuses (Critical line, application not running): nothing was dropped (the copy is a transaction and the drop never ran). Fix the cause named in the message and start again; or deploy the previous release, which still reads `HeroImages`... only if the Hero migrations before the drop are compatible: those migrations (crop columns on slides, foreign key removal) are additive and the previous release ignores them, except that the foreign key `FK_HeroSlides_HeroImages_ImageId` is gone (the old release works without it). - Media files are never touched by any of this. - `Media__AutoCleanupUnattached` is off by default (unused uploads stay until deleted in the library). - Test already ran the staged road; the one-shot path is tested on MariaDB in `HeroPhotosInLibraryTableTests.One_release_from_the_old_state_...` (hero tables just before phase 2, photos incl. a trashed one, no library tables) and should be tried on test once before production (restore the test database to a state before phase 2 if Bryan wants a rehearsal).