Skip to content

Instantly share code, notes, and snippets.

@fgrehm
Created April 22, 2013 16:26
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save fgrehm/5436485 to your computer and use it in GitHub Desktop.
Save fgrehm/5436485 to your computer and use it in GitHub Desktop.
if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"
fi
@poredaka
Copy link

Thank you!

@koleror
Copy link

koleror commented Mar 7, 2019

Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment