Rails schema.rb for different databases

I have a problem with schema.rb in Rails. If I run rake db:migrate , the results will be different for different databases, to be precise, if I use PostgreSQL and the text field that it gives me

 t.text "summary" 

but with SQLite it gives me

 t.text "summary", :limit => 255 

Also, when I use :default , the number of spaces varies, PostgreSQL:

 t.boolean "watched", :default => false, :null => false 

SQLite:

 t.boolean "watched", :default => false, :null => false 

It is very annoying that when I run rake db:migrate during production, it changes my schema.rb and, obviously, I cannot use rake db:schema:load when creating when using schema.rb generated in the development environment. My question is why there are differences and how do they resolve them, so is schema.rb the same for production and development?

+4
source share
1 answer

For your own sanity, I would recommend using the same database engine for development as in production. It does not take too much effort to get up and work with the local MySQL or PostgreSQL server, and you will avoid unpleasant surprises by doing all your development and testing on the same backend that you will use, production.

+10
source

Source: https://habr.com/ru/post/1338501/


All Articles