开发者

Inconsistent Rails database schema generation for boolean fields

Rails version = 2.3.8

When comparing the schemas of two of my sites, each with an almost identical codebase, I noticed something very strange. For the exact same table, the schema of one site shows:

t.integer  "member_feed",   :limit => 1, :default => 1

and for the other:

t.boolean  "member_feed",   :default => true

There was no difference in the way the two were created. In fact, the first one was actually extracted from the second when the site was created. This first schema had at least 40 different cases where boolean was displayed incorrectly, and I had to go in and change each one with a change_c开发者_如何学编程olumn migration. Note that there is definitely a difference in functionality when boolean is not explicitly defined.

Anybody have an idea as to what may be causing this? Thanks.


This happens when you run migrations from different Operating Systems. It's not rails' mysql that's at fault, but actual mysql.

Some versions of it just don't store the fact that there are limits and other flags... usually ones that actually have a built-in boolean class thus removing the necessity for a limit => 1 (you'll find it also failing to store some versions of "precision" for decimal values too)

The problem comes in because that mysql assumes that all other versions have a built-in class... and of course they don't.

This is an integrated-systems bug that really can't be fixed. Sorry. :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜