Add db migrations, update watch.sh for uv + idempotent runs

- Schema versioned with migrations table
- watch.sh runs db migrations on every pull
- watch.sh uses uv run/sync instead of pip
- Fixed parser.py reference in watch.sh
This commit is contained in:
Jarvis Prime
2026-03-04 04:32:17 +00:00
parent 9680dc07eb
commit 20253329e4
2 changed files with 50 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ start_mcp() {
wait "$MCP_PID" 2>/dev/null || true
fi
echo "[watch] Starting MCP server..."
python mcp_server.py &
uv run python mcp_server.py &
MCP_PID=$!
echo "[watch] MCP server started (pid $MCP_PID)"
}
@@ -52,7 +52,7 @@ echo ""
# Initial setup
LAST_HASH=$(get_local_hash)
LAST_REQS=$(md5sum requirements.txt 2>/dev/null || echo "none")
LAST_REQS=$(md5sum requirements.txt pyproject.toml 2>/dev/null || echo "none")
# Start MCP server
if [ -f "devintel.db" ]; then
@@ -82,19 +82,23 @@ while true; do
git pull --ff-only origin master
# Check if requirements changed
NEW_REQS=$(md5sum requirements.txt 2>/dev/null || echo "none")
NEW_REQS=$(md5sum requirements.txt pyproject.toml 2>/dev/null || echo "none")
if [ "$NEW_REQS" != "$LAST_REQS" ]; then
echo "[watch] requirements.txt changed — reinstalling..."
pip install -r requirements.txt
echo "[watch] Dependencies changed — syncing..."
uv sync
LAST_REQS="$NEW_REQS"
fi
# Always run db migrations
echo "[watch] Running db migrations..."
uv run python -c "from db import init_db; init_db()"
# Check if ingestion code changed
CHANGED_FILES=$(git diff --name-only "$LOCAL_HASH" "$REMOTE_HASH")
NEEDS_REINGEST=false
for f in $CHANGED_FILES; do
case "$f" in
parser.py|docgen.py|ingest.py|db.py)
go_parser.py|docgen.py|ingest.py|db.py)
NEEDS_REINGEST=true
;;
esac
@@ -102,7 +106,7 @@ while true; do
if [ "$NEEDS_REINGEST" = true ] && [ -f "devintel.db" ]; then
echo "[watch] Ingestion code changed. Re-running ingestion..."
python ingest.py
uv run python ingest.py
fi
# Always restart MCP server on any code change