简体   繁体   中英

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 .

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 "{}" . Routine operations such as rake db:schema:dump cause destructive diffs like the following:

-    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.

Naturally, this problem wreaks all sorts of havoc. Short of switching to a SQL structure dump, how can I get proper schema dumps?

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 4 handles more types when using rake db:schema:dump , which is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM