Een weigerende guard stopt de applicatie nu echt (ModuleStartupException wordt door de orchestrator doorgegooid). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3.9 KiB
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:
HeroModule.UseModulecallsHeroImagesDropGuard.PrepareAndVerify. If the migrationDropHeroImagesTableis pending:- the hero's own migrations up to the one before the drop are applied (so
HeroImageshas its final columns); - if
HeroImagesholds photos: the library tables are brought to the current schema throughIMediaLibrarySchema(implemented by the Media module, which runs its migrations; this makes the order in which modules start irrelevant) and the photos are copied intoMediaAssets(modulehero): rows that differ are updated, missing rows inserted, nothing is deleted. HeroImages is the truth at that moment. The copy is one transaction; Verify(unchanged, strict) compares hash, set hash and variants of every photo; on any difference it throwsModuleStartupException;- 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
HeroImagesjust 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 keyFK_HeroSlides_HeroImages_ImageIdis gone (the old release works without it). - Media files are never touched by any of this.
Media__AutoCleanupUnattachedis 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).