6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CircleCIでno-localeなPostgreSQLのDBを作成する

Posted at

Collate=CのPostgreSQLデータベースとは?

PostgreSQLで感覚的に正しい日本語ソートを行うにはinitdb時に--no-localeオプションを付けて初期化を行う必要がある。CircleCIではデフォルトでUTF-8なので正しくテストを実行することができない可能性がある。

強制的にno-localeなDBを作り直す

circle.ymlに次のように指定することでno-localeなDBを強制的に再作成することができる。

machine:
  ruby:
    version: 2.2.1
  pre:
    - sudo locale-gen ja_JP.UTF-8
    - sudo -E -u postgres PGDATA=/var/lib/postgresql/9.4/main /usr/lib/postgresql/9.4/bin/pg_ctl stop
    - sudo -E -u postgres rm -r /var/lib/postgresql/9.4/main
    - sudo -E -u postgres PGDATA=/var/lib/postgresql/9.4/main /usr/lib/postgresql/9.4/bin/initdb --encoding=UTF8 --no-locale --username=ubuntu
    - sudo -E -u postgres PGDATA=/var/lib/postgresql/9.4/main /usr/lib/postgresql/9.4/bin/pg_ctl start
  timezone:
    Asia/Tokyo
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?