mozilla / chronicle

find everything you've ever found
http://mozillachronicle.tumblr.com/
Mozilla Public License 2.0
16 stars 6 forks source link

db create script: specify template to avoid collation errors #367

Closed jaredhirsch closed 9 years ago

jaredhirsch commented 9 years ago

If the user is on a system where en_US.UTF-8 isn't the default collation, attempting to create_db will fail with an error like:

ERROR:  new collation (en_US.UTF-8) is incompatible with the collation of the template
database (C)
HINT:  Use the same collation as in the template database, or use template0 as template.

One solution which seems to work is to specify the template from which the database should be built. So, we'd replace this line:

psql -c "CREATE DATABASE chronicle ENCODING 'UTF-8' LC_COLLATE = 'en_US.UTF-8' 
  LC_CTYPE = 'en_US.UTF-8';" -U $PSQLUSER

with

psql -c "CREATE DATABASE chronicle ENCODING 'UTF-8' LC_COLLATE = 'en_US.UTF-8' 
  LC_CTYPE = 'en_US.UTF-8' TEMPLATE template0;" -U $PSQLUSER

Solution reference: http://stackoverflow.com/questions/18870775/how-to-change-the-template-database-collection-coding-on-postgresql