简体   繁体   English

Rails 3.2模式转储使用postgres_ext gem将所有UUID列转换为text和mangles数组声明

[英]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.

相关问题 在postgis适配器中使用postgres_ext不适用于数组列 - Using postgres_ext with postgis adapter not working with array columns 计算Active Admin仪表板(Rails,Active admin 1.0,Postgresql数据库,postgres_ext gem)中序列化属性(数组)中值的出现 - Count occurrence of values in a serialized attribute(array) in Active Admin dashboard (Rails, Active admin 1.0, Postgresql database, postgres_ext gem) 修补ActiveRecord / postgres_ext以返回大写的UUID - Patch ActiveRecord/postgres_ext to return upper case UUID 尝试在Active Admin table_for(Rails,Postgresql,postgres_ext gem)上使用数组数据时,[xxx]的错误未定义方法`to_key':Array: - Error undefined method `to_key' for [xxx] :Array when trying to use array data on Active Admin table_for (Rails, Postgresql, postgres_ext gem) Rails和Postgres数组列 - Rails and Postgres array columns Rails 3.2和Paloma gem - Rails 3.2 and Paloma gem postgres_ext / serializers help ...看起来很简单,但无法按照描述获得任何工作 - postgres_ext/serializers help… seems so simple, but can't get anything to work as described Rails Postgres GROUP所有列 - Rails Postgres GROUP all columns 转储postgres DB导轨 - Dump postgres DB rails Google Analytics(分析)的宝石(Rails 3.2) - Gem for Google Analytics (Rails 3.2)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM