CircleCI with Rails, PostgreSQL and custom collation
At Oktavilla we are in the process of moving a RubyOnRails application from MySQL to PostgreSQL. For this appliction we use the excellent CircleCI to automatically run the test suit when new commits are pushed to GitHub. This application is in swedish so we want to setup the database with collation set to sv_SE.UTF-8
to make sorting work correctly.
This didn’t work out of the box on CircleCI. After some testing and reading we ended up with this.
A custom database.yml
for CircleCI. Create a file in config/database.ci.yml with:
Note that collation
and template
is set. Read more on PostgreSQL database templates in the docs.
Our circle.yml
looks like this:
First we have to create the system locale using locale-gen
. This requires a restart of PostgreSQL and some sleep time to let it finish the startup sequence. Then we override the default database setup and use our own database.ci.yml
and create the database.