[英]Rails 3.2 schema dump turns all UUID columns to text and mangles array declarations with postgres_ext gem
Using Ruby 2.0.0-p195 with Rails 3.2.13 and v0.3.1 of the postgres_ext gem . 使用Ruby 2.0.0-p195和postgres_ext gem的 Rails 3.2.13和v0.3.1。
It seems that I often have trouble with schema dumps (not SQL structure dumps) using Rails wherein the schema dumper converts UUID columns to text columns and arrays to text columns with defaults of "{}"
. 我似乎经常使用Rails进行模式转储(而不是SQL结构转储),其中模式转储器将UUID列转换为文本列,将数组转换为默认为
"{}"
文本列。 Routine operations such as rake db:schema:dump
cause destructive diffs like the following: 诸如
rake db:schema:dump
类的常规操作会导致破坏性差异,如下所示:
- t.string "dbas", :default => [], :array => true
- t.string "industries", :default => [], :array => true
+ t.text "dbas", :default => "{}"
+ t.text "industries", :default => "{}"
- t.uuid "uuid"
+ t.text "uuid"
If I examine the structure of the DB manually or just ask Rails what type of column type it thinks a given attribute has, everything looks just fine. 如果我手动检查数据库的结构或只是询问Rails它认为给定属性有哪种类型的列类型,一切看起来都很好。
Naturally, this problem wreaks all sorts of havoc. 当然,这个问题会造成各种各样的破坏。 Short of switching to a SQL structure dump, how can I get proper schema dumps?
如果没有切换到SQL结构转储,我怎样才能获得正确的架构转储?
With Rails 3.2, you'll need to use rake db:structure:dump
to dump the SQL version of the schema instead of the Ruby version. 使用Rails 3.2,您需要使用
rake db:structure:dump
来转储模式的SQL版本而不是Ruby版本。
Rails 4 handles more types when using rake db:schema:dump
, which is what you are looking for. 使用
rake db:schema:dump
,Rails 4会处理更多类型,这正是您要查找的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.