简体   繁体   中英

Rails schema.rb different for different databases

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

t.text     "summary"

line, but with SQLite it gives me

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

Also when I use :default , number of spaces differ, PostgreSQL:

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

SQLite:

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

It is quite annoying that when I run rake db:migrate on production it changes my schema.rb and obviously I can't use rake db:schema:load on production when using schema.rb generated in development environment. My question is why are there differences and how do I make them disappear, so schema.rb is the same for production and development?

For your own sanity, I'd recommend using the same DB engine in development as you do in production. It doesn't take too much effort to get up and running with a local PostgreSQL server, and you'll avoid some nasty surprises by doing all of your development and testing on the same backend you're using in production.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM