diff --git a/ruby_on_rails/app_initialisation.md b/ruby_on_rails/app_initialisation.md index 2a1ef551..73b0a8f4 100644 --- a/ruby_on_rails/app_initialisation.md +++ b/ruby_on_rails/app_initialisation.md @@ -40,6 +40,10 @@ Some other adjustments must be performed manually. ### Automatic adjustments +> ⭐️The `config/database.yml` is updated to have a `collation: C.UTF-8` setting. +> This ensures deterministic, locale-independent sorting and avoids inconsistencies between local and production +> environments. + > ⭐The Gemfile reads the required ruby version from the `.ruby-version` file. > [This is used by Heroku to determine what version to use.](https://devcenter.heroku.com/articles/ruby-versions) > 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 diff --git a/ruby_on_rails/template.rb b/ruby_on_rails/template.rb index 7d1d159c..bdb1c73f 100644 --- a/ruby_on_rails/template.rb +++ b/ruby_on_rails/template.rb @@ -1,5 +1,9 @@ -# replace rubocop-rails-omakase with renuocop +# configure the database collation +insert_into_file "config/database.yml", after: "adapter: postgresql\n" do + " template: template0\n collation: C.UTF-8\n" +end +# replace rubocop-rails-omakase with renuocop gsub_file "Gemfile", /gem "rubocop-rails-omakase"/, "gem \"renuocop\"" insert_into_file "Gemfile", after: /^group :development do\n/ do diff --git a/templates/config/database.mysql.example.yml b/templates/config/database.mysql.example.yml deleted file mode 100644 index 051c3a37..00000000 --- a/templates/config/database.mysql.example.yml +++ /dev/null @@ -1,20 +0,0 @@ -mysql: &mysql - adapter: mysql2 - encoding: utf8 - host: localhost - reconnect: true - pool: 5 - username: "" - password: "" - -development: - <<: *mysql - database: _development - -test: - <<: *mysql - database: _test - -production: - <<: *mysql - database: _production diff --git a/templates/config/database.sqlite.example.yml b/templates/config/database.sqlite.example.yml deleted file mode 100644 index 40593185..00000000 --- a/templates/config/database.sqlite.example.yml +++ /dev/null @@ -1,16 +0,0 @@ -sqlite: &sqlite - adapter: sqlite3 - pool: 5 - timeout: 5000 - -development: - <<: *sqlite - database: db/development.sqlite3 - -test: - <<: *sqlite - database: db/test.sqlite3 - -production: - <<: *sqlite - database: db/production.sqlite3 diff --git a/templates/config/database.yml b/templates/config/database.yml deleted file mode 100644 index 286f529d..00000000 --- a/templates/config/database.yml +++ /dev/null @@ -1,21 +0,0 @@ -# For details on connection pooling, see rails configuration guide -# http://guides.rubyonrails.org/configuring.html#database-pooling - -default: &default - adapter: postgresql - encoding: unicode - pool: <%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 5 %> - # Minimum log levels, in increasing order: debug5, debug4, debug3, debug2, debug1, log, notice, warning, error, - # fatal, and panic. Defaults to warning. min_messages: warning - url: <%= ENV['DATABASE_URL'] %> - -development: - <<: *default - database: _development - -test: - <<: *default - database: _test - -production: - <<: *default