Created
February 5, 2024 06:21
-
-
Save Edu4rdSHL/80b63375730c6f2104dac62ea12cb97f to your computer and use it in GitHub Desktop.
Fix postgres collation version mismatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# PostgreSQL connection parameters | |
PG_USER="postgres" | |
PG_HOST="localhost" | |
PG_PORT="5432" | |
# Get a list of databases | |
databases=$(psql -U $PG_USER -h $PG_HOST -p $PG_PORT -q -t -c "SELECT datname FROM pg_database") | |
# Iterate through each database and execute the command | |
for database in $databases; do | |
echo "Refreshing collation version for database: $database" | |
psql -U $PG_USER -h $PG_HOST -p $PG_PORT -d $database -c "REINDEX DATABASE $database" | |
psql -U $PG_USER -h $PG_HOST -p $PG_PORT -d $database -c "ALTER DATABASE $database REFRESH COLLATION VERSION" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment