Ubuntu-10.04にしたらPostgreSQLでrake db:createができない
10.04にしたらPostgreSQLは8.4になりました。
psql -lの結果もちょっと違います。
$ psql -l List of databases Name | Owner | Encoding ---------------------+----------+----------- postgres | postgres | SQL_ASCII redmine | fujioka | UTF8 template0 | postgres | SQL_ASCII template1 | postgres | SQL_ASCII (4 rows)
こんな感じだったのに、
$ psql -l List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges -----------+----------+-----------+-----------+-------+----------------------- postgres | postgres | SQL_ASCII | C | C | redmine | redmine | UTF8 | C | C | template0 | postgres | SQL_ASCII | C | C | =c/postgres : postgres=CTc/postgres template1 | postgres | SQL_ASCII | C | C | =c/postgres : postgres=CTc/postgres (4 rows)
こんな感じです。
それでいつものようにrake db:createとやってもdbが作成されません。
createdb -Eunicode hogeとやってみると
$ createdb -Eunicode hoge createdb: database creation failed: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.
と出ます。エラーメッセージにtemplate0を使えと書いているので、
$ createdb -Eunicode -T template0 hoge $ psql -l List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges -----------+----------+-----------+-----------+-------+----------------------- hoge | redmine | UTF8 | C | C | postgres | postgres | SQL_ASCII | C | C | redmine | redmine | UTF8 | C | C | template0 | postgres | SQL_ASCII | C | C | =c/postgres : postgres=CTc/postgres template1 | postgres | SQL_ASCII | C | C | =c/postgres : postgres=CTc/postgres (5 rows)
というわけで、template0を使えということでした。