Files
state-hub/migrations/versions/g4b5c6d7e8f9_add_host_paths_to_repos.py
tegwick 82552b8d59 feat(repos): multi-machine path support via host_paths
Adds a JSONB column `host_paths` to managed_repos mapping
hostname → absolute local path. Fixes the consistency-checker
failure when the same repo lives at different paths on different
machines (e.g. /home/worsch/marki-docx on the workstation vs
/home/tegwick/marki-docx on custodiancore).

Changes:
- Migration g4b5c6d7e8f9: adds host_paths JSONB (default {})
- Model: host_paths Mapped[dict] column
- Schemas: host_paths in RepoRead; new RepoPathRegister schema
- Router: POST /repos/{slug}/paths/ — merges one host entry
- consistency_check.py: resolve_repo_path() prefers host_paths
  [hostname] over local_path; --repo-path CLI override added
- MCP: update_repo_path(slug, path, host?) tool
- Makefile: register-path target; REPO_PATH passthrough on
  check-consistency and fix-consistency targets
- TOOLS.md: documents update_repo_path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 16:30:55 +01:00

39 lines
1.0 KiB
Python

"""add host_paths to managed_repos
Revision ID: g4b5c6d7e8f9
Revises: f3a4b5c6d7e8
Create Date: 2026-03-16
Adds a JSONB column `host_paths` to managed_repos mapping hostname → absolute
local path. This allows the same repo to be registered at different paths on
different machines (e.g. /home/worsch/marki-docx on the workstation and
/home/tegwick/marki-docx on custodiancore). The consistency checker and any
other path-resolving code prefers host_paths[current_hostname] over local_path.
"""
from __future__ import annotations
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = "g4b5c6d7e8f9"
down_revision = "f3a4b5c6d7e8"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"managed_repos",
sa.Column(
"host_paths",
postgresql.JSONB(astext_type=sa.Text()),
nullable=False,
server_default="{}",
),
)
def downgrade() -> None:
op.drop_column("managed_repos", "host_paths")