My database uses PostgreSQL. I develop on Mac and this line is needed:
# db/schema.rb on Mac environment
enable_extension "plpgsql"
However, the extension is not required on Linux.
In this case, should we just ignore schema.rb and generate that through db:migrate for both dev and production environments?
The schema. rb serves mainly two purposes: It documents the final current state of the database schema. Often, especially when you have more than a couple of migrations, it's hard to deduce the schema just from the migrations alone.
Unlike rake db:migrate that runs migrations that have not run yet, rake db:schema:load loads the schema that is already generated in db/schema. rb into the database. Always use this command when: You run the application for the first time.
structure. sql instead is a SQL representation of the database and it depends on the specific database you selected. You only use the structure if you have specific database features that you need and that can't be represented by the schema.
As far as I understood it, the problem is that the auto-generated schema.rb will differ on production and development, and therefore cause changed files in git, because of this extra line.
Is the line generated by the postgres adapter on mac ? If it's been added manually, I'd try to put it somewhere else, maybe in an initializer (where you could switch its use based on the platform via something from here: Detecting Operating Systems in Ruby ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With