Marek Sapota
Marek Sapota

Reputation: 20591

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?

Upvotes: 5

Views: 1545

Answers (1)

Ernie
Ernie

Reputation: 906

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.

Upvotes: 12

Related Questions