From c9b30d9ec91ee51d883d40a79c665b48d88a7f5d Mon Sep 17 00:00:00 2001 From: Justin Clift Date: Mon, 30 Sep 2024 21:08:32 +1000 Subject: [PATCH] Start figuring out how to automatically reindex the database cluster --- docker-entrypoint.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 01aa5a8..4f5d90a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -572,6 +572,27 @@ _main() { echo "Removing left over database files is complete" echo "---------------------------------------------" + # Automatically reindex the databases (if requested) + if [ "${PGAUTO_REINDEX}" = "yes" ]; then + echo "------------------------" + echo "Reindexing the databases" + echo "------------------------" + + # Start the database in single user mode + "${OLDPATH}/bin/postgres" --single -D "${POSTGRES_DB}" + + # 1. Get the list of databases in the database cluster + # Something like this should work: + # SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE; + + # 2. For each database, get the list of indexes + # 3. Regenerate the indexes + + echo "-------------------------------" + echo "End of reindexing the databases" + echo "-------------------------------" + fi + echo "**********************************************************" echo "Automatic upgrade process finished with no errors reported" echo "**********************************************************"