Skip to content

Commit 995d7b3

Browse files
committed
Specify collation for Postgres DBs
I do think it makes sense to use C.UTF-8 as it does not depend on OS locale settings and hence is deterministic across Postgres instances. With en_US.UTF-8 any updates to glibc or ICU could affect the existing sorting order. If it is really needed, it can still be defined on column level.
1 parent 052b5d4 commit 995d7b3

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

ruby_on_rails/app_initialisation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Some other adjustments must be performed manually.
4040

4141
### Automatic adjustments
4242

43+
> ⭐️The `config/database.yml` is updated to have a `collation: C.UTF-8` setting.
44+
> This ensures deterministic, locale-independent sorting and avoids inconsistencies between local and production
45+
> environments.
46+
4347
> ⭐The Gemfile reads the required ruby version from the `.ruby-version` file.
4448
> [This is used by Heroku to determine what version to use.](https://devcenter.heroku.com/articles/ruby-versions)
4549
> Deploio reads the ruby version from the Gemfile, with the .ruby-version file inlined into it. https://paketo.io/docs/howto/ruby/#override-the-detected-ruby-version

ruby_on_rails/template.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# replace rubocop-rails-omakase with renuocop
1+
# configure the database collation
2+
insert_into_file "config/database.yml", after: "adapter: postgresql\n" do
3+
" template: template0\n collation: C.UTF-8\n"
4+
end
25

6+
# replace rubocop-rails-omakase with renuocop
37
gsub_file "Gemfile", /gem "rubocop-rails-omakase"/, "gem \"renuocop\""
48

59
insert_into_file "Gemfile", after: /^group :development do\n/ do

0 commit comments

Comments
 (0)