diff --git a/infra/scripts/deploy-erosi.sh b/infra/scripts/deploy-erosi.sh index 3d5ea1c..017bfd8 100755 --- a/infra/scripts/deploy-erosi.sh +++ b/infra/scripts/deploy-erosi.sh @@ -206,6 +206,16 @@ for f in supabase/migrations/*.sql; do fi done +# Force PostgREST to reload its schema cache. Without this, RPCs added in +# the migrations above 404 with "Could not find the function ... in the +# schema cache" until the rest container is restarted. Confirmed bug on +# 2026-05-18 after migration 026 added set_item_frequency_weight + +# purge_item_frequency. NOTIFY is cheaper than a container restart. +echo "--- Reloading PostgREST schema cache" +docker compose --env-file .env -f infra/docker-compose.erosi.yml exec -T db \ + psql -U postgres -d postgres /dev/null || echo "") deploy_ts=$(date -u +"%Y-%m-%dT%H:%M:%SZ") diff --git a/infra/scripts/rollback-erosi.sh b/infra/scripts/rollback-erosi.sh index c9ffdcc..e1a91f3 100755 --- a/infra/scripts/rollback-erosi.sh +++ b/infra/scripts/rollback-erosi.sh @@ -175,6 +175,13 @@ cd /opt/colectivo GIT_SHA="$GIT_SHA" docker compose --env-file .env -f infra/docker-compose.erosi.yml \ build --build-arg GIT_SHA="$GIT_SHA" app GIT_SHA="$GIT_SHA" docker compose --env-file .env -f infra/docker-compose.erosi.yml up -d + +# Reload PostgREST schema cache so any RPCs that changed shape between +# the rolled-back schema and the current rest container snapshot are +# resolved. Mirrors the same step at the end of deploy-erosi.sh. +docker compose --env-file .env -f infra/docker-compose.erosi.yml exec -T db \ + psql -U postgres -d postgres