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 "**********************************************************"