Rails generates incomplete schema

Is it possible to get the generated schema.rb to include accurately
reflect your database’s schema?

For example, when using usesguid plugin, we change the primary key
from id, int(11), autoincrement to say, guid, varchar(22)

The schema file picks up the change of id to guid, but not the type.
So when the test DB is created from schema.rb, the guid column is int
(11) autoincrement. This causes havoc with unit tests and does not
accurately depict the production environment.

How do people deal with this? It’s driving me crazy.

Similarly, adding a new column as integer autoincrement that is not
the primary key is also not reflected in schema.rb and completely
breaks fixtures.

Any help would be appreciated,


Apparently config.active_record.schema_format = :sql in environment.rb
was the trick I was looking for.

Not very obvious. Not obvious that your test DB schema will be
different than your dev/prod schema should you start putting weird
stuff in your migrations.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs