fix(§22): heal mig-029 vs registry-mirror collection-id divergence
On a deployment that already had >=2 projects when migration 029 ran, 029 seeds the default project's collection id as the project id (e.g. 'ohm'), but the registry mirror expects 'default' -> it inserted a duplicate empty 'default' collection, orphaning the entries. Adds projects.reconcile_default_collection_id() -- the collection-grain twin of restamp_default_project -- run at startup BEFORE the mirror so it merges onto the canonical 'default' collection instead of duplicating. Renames the divergent collection id and cascades collection_id across all keyed tables (FK-off atomic rename + foreign_key_check). Idempotent; no-op on fresh / single-project / already-aligned deploys. Seam tests show the duplicate forms without the fix and merges with it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,12 @@ async def lifespan(app: FastAPI):
|
||||
db.run_migrations(config)
|
||||
db.init(config)
|
||||
gitea = Gitea(config)
|
||||
# §22 framework heal: reconcile a divergent default-project collection id
|
||||
# (migration 029's ≥2-projects seed names it after the project, e.g. 'ohm',
|
||||
# but the mirror expects 'default') BEFORE the mirror runs, so the mirror
|
||||
# merges onto the canonical 'default' collection instead of duplicating it.
|
||||
# Idempotent no-op on fresh / single-project / already-aligned deployments.
|
||||
projects.reconcile_default_collection_id(config)
|
||||
# §22.2: mirror the registry before anything reads projects/content_repo.
|
||||
# First boot has no last-good rows, so a missing/invalid registry is fatal
|
||||
# (loud-fail per separation-of-concerns); the reconciler sweep keeps it
|
||||
|
||||
Reference in New Issue
Block a user