Rails 5 - ENV DATABASE_URL - specify encoding and collation
<p>Our database.yml is added to <code>.gitignore</code> so devs can customize local environments and we plan to use <code>ENV['DATABASE_URL']</code> for production servers. For default setup, this works. However, we need to configure <code>encoding</code> and <code>collation</code> to <code>utf8mb4</code>.</p>

<ul>
<li>encoding: utf8mb4</li>
<li>collation: utf8mb4_unicode_ci</li>
</ul>

<p>I tried padding it to query parameters, like the <code>?pool=5</code> example in the docs, but it doesn't seem to work.</p>

<pre><code>DATABASE_URL=mysql2://user:passwd@host:port/dbname?encoding=utf8mb4&amp;collation=utf8mb4_unicode_ci
</code></pre>

<p>The tables created are still using the default encoding/collation so I assume the parameters doesn't work. Is there any way I could configure this by any other methods? Encoding and collation is the same for all environments.</p>

<p>Requirement is that dev environment can have a file with a config whereas prod should have no special file added, it should only use ENV variables. Maybe add this to one of the files inside config dir like application.rb or other files?</p>

<p>Thanks in advance.</p>

<p>PS: I'm new to Rails and Ruby (1 week) since I'm coming from PHP/Python.</p>