From bbe54cf6568e0677f6c828f01ee1a567632d821e Mon Sep 17 00:00:00 2001 From: Antigravity Date: Tue, 12 May 2026 07:46:07 +0000 Subject: [PATCH] fix: force recreate postgres with pgvector before app startup in deploy pipeline --- .gitea/workflows/deploy.yaml | 27 ++++++++++++++++++++-- DEPLOY-ISSUES-2.md | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 DEPLOY-ISSUES-2.md diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index f381630..f99b35c 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -124,12 +124,35 @@ jobs: git fetch origin main git reset --hard origin/main - echo "=== Building ===" + echo "=== Pull & recreate postgres with pgvector ===" docker compose pull postgres + docker compose up -d --force-recreate postgres + + echo "=== Waiting for postgres healthy ===" + for i in $(seq 1 30); do + if docker compose exec -T postgres pg_isready -U "${POSTGRES_USER:-memento}" >/dev/null 2>&1; then + echo "Postgres healthy after $((i * 2))s" + break + fi + if [ "$i" -eq 30 ]; then + echo "ERROR: Postgres not healthy after 60s" + docker compose logs postgres --tail=30 + exit 1 + fi + sleep 2 + done + + echo "=== Create vector extension ===" + docker compose exec -T postgres psql -U "${POSTGRES_USER:-memento}" -d "${POSTGRES_DB:-memento}" -c "CREATE EXTENSION IF NOT EXISTS vector;" + + echo "=== Resolve failed prisma migrations ===" + docker compose exec -T postgres psql -U "${POSTGRES_USER:-memento}" -d "${POSTGRES_DB:-memento}" -c "UPDATE \"_prisma_migrations\" SET \"finished_at\"=NOW(), \"rolled_back_at\"=NULL WHERE \"finished_at\" IS NULL AND \"rolled_back_at\" IS NULL;" || true + + echo "=== Building app images ===" docker compose build memento-note docker compose build mcp-server - echo "=== Starting ===" + echo "=== Starting app containers ===" docker compose up -d --remove-orphans docker compose ps ENDSSH diff --git a/DEPLOY-ISSUES-2.md b/DEPLOY-ISSUES-2.md new file mode 100644 index 0000000..7f599af --- /dev/null +++ b/DEPLOY-ISSUES-2.md @@ -0,0 +1,44 @@ +# Deployment Still Failing — 502 Error + +## Date: 2026-05-12 (second attempt) + +## Problem +After push of dc4244f, deploy relaunched BUT: +- postgres container was NOT recreated with new pgvector/pgvector:pg16 image +- Still running postgres:16-alpine — no pgvector — type "vector" does not exist +- docker compose pull postgres added in deploy.yaml is not enough — need docker compose up -d --force-recreate postgres + +## Production logs (192.168.1.190) +- memento-web: Restarting loop +- memento-postgres: healthy but STILL on postgres:16-alpine +- Error: type "vector" does not exist + +## Root cause +deploy.yaml does docker compose build then docker compose up -d BUT: +- postgres has no build: directive — uses image directly +- docker compose up -d does NOT recreate container if image didnt change locally +- Even with docker compose pull, existing container may not be recreated + +## What must be fixed + +### 1. deploy.yaml (.gitea/workflows/deploy.yaml) +Add BEFORE docker compose up -d: +- docker compose pull postgres +- docker compose up -d --force-recreate postgres +- Wait for postgres healthy before continuing +Or use: docker compose up -d --force-recreate --build + +### 2. Verify docker-compose.yml has correct image +image: pgvector/pgvector:pg16 + +### 3. Prisma migration is stuck +Old migration 20260512120000_pgvector_and_fts_search marked as failed in _prisma_migrations. +Need to mark it resolved after pgvector is installed. + +### 4. Correct deployment order +1. Pull + recreate postgres with pgvector +2. Wait postgres healthy +3. Create vector extension: CREATE EXTENSION IF NOT EXISTS vector +4. Resolve failed migration in _prisma_migrations +5. Start memento-web (will run migration) +6. Start mcp-server