# Rails generates incomplete schema

**URL:** <https://www.ruby-forum.com/t/rails-generates-incomplete-schema/166730>\
**Category:** Rails\
**Created:** [April 29, 2009, 12:38am UTC](https://www.ruby-forum.com/t/rails-generates-incomplete-schema/166730 "2009-04-29T00:38:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blgroup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/eb8c5e/32.png) [@blgroup](https://www.ruby-forum.com/u/blgroup)\
**Post date:** [April 29, 2009, 12:38am UTC](https://www.ruby-forum.com/t/rails-generates-incomplete-schema/166730/1 "2009-04-29T00:38:24Z")

</div>

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,

Thanks,  
=Blair.

---

<div class="post-metadata">

**Author:** ![blgroup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/eb8c5e/32.png) [@blgroup](https://www.ruby-forum.com/u/blgroup)\
**Post date:** [April 29, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/rails-generates-incomplete-schema/166730/2 "2009-04-29T21:17:48Z")

</div>

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.

=Blair.
