Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 643
Marek Sapota Avatar asked Feb 04 '11 21:02

Marek Sapota


Video Answer


1 Answers

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.

like image 166
Ernie Avatar answered Sep 30 '22 17:09

Ernie