@@ -149,8 +149,9 @@ echo "🧹 cleanup for indices: $approved_words from $indices"
149149echo " --------------------------"
150150for index in ${indices[@]} ; do
151151 for approved in $approved_words ; do
152+ echo " Checking index $index against approved pattern $approved ..."
152153 case " $index " in
153- " $approved_words " * )
154+ " $approved " * )
154155 echo " Delete index $index ..."
155156 docker run --rm --network=$NETWORK appropriate/curl curl -sS -XDELETE " http://$( elasticsearch_host) /$index "
156157 break
@@ -214,7 +215,7 @@ if [ -f "$ROOT_PATH/backups/postgres/events-${LABEL}.dump" ]; then
214215 -e PGPASSWORD=$POSTGRES_PASSWORD \
215216 --network=$NETWORK \
216217 postgres:17.6 \
217- bash -c " psql -h postgres -U $POSTGRES_USER -c 'DROP DATABASE IF EXISTS events;'"
218+ bash -c " psql -h postgres -U $POSTGRES_USER -c 'DROP DATABASE IF EXISTS events WITH (FORCE) ;'"
218219else
219220 echo " PostgreSQL backup not found for label ${LABEL} . Skipping PostgreSQL database drop..."
220221fi
@@ -252,7 +253,11 @@ if [ -f "$ROOT_PATH/backups/postgres/events-${LABEL}.dump" ]; then
252253 -v $ROOT_PATH /backups/postgres:/backups \
253254 --network=$NETWORK \
254255 postgres:17.6 \
255- bash -c " createdb -h postgres -U $POSTGRES_USER events && pg_restore -h postgres -U $POSTGRES_USER -d events /backups/events-${LABEL} .dump"
256+ bash -c " createdb -h postgres -U $POSTGRES_USER events && \
257+ psql -h postgres -U $POSTGRES_USER -d events -c 'CREATE SCHEMA app AUTHORIZATION events_migrator; GRANT USAGE ON SCHEMA app TO events_app;' && \
258+ pg_restore -h postgres -U $POSTGRES_USER -d events --schema=app /backups/events-${LABEL} .dump"
259+ echo " Update credentials in Postgres on restore"
260+ docker service update --force opencrvs_postgres-on-update
256261else
257262 echo " PostgreSQL backup not found for label ${LABEL} . Skipping PostgreSQL database restore..."
258263fi
@@ -309,3 +314,15 @@ tar -xzvf $ROOT_PATH/backups/vsexport/ocrvs-$LABEL.tar.gz -C $ROOT_PATH/vsexport
309314if [ " $IS_LOCAL " = false ]; then
310315 docker service update --force --update-parallelism 1 opencrvs_migration
311316fi
317+
318+ # #
319+ # ------ REINDEX -----
320+ # #
321+ docker run --rm \
322+ -v /opt/opencrvs/infrastructure/deployment:/workspace \
323+ -w /workspace \
324+ --network $NETWORK \
325+ -e ' AUTH_URL=http://auth:4040/' \
326+ -e ' EVENTS_URL=http://gateway:7070/events' \
327+ alpine \
328+ sh -c ' apk add --no-cache curl jq && sh reindex.sh'
0 commit comments