5

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?

Patsy Issa
  • 11,113
  • 4
  • 55
  • 74
yonkeltron
  • 643
  • 5
  • 7

1 Answers1

1

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.

phlipper
  • 1,834
  • 15
  • 14
  • Postgres_ext provides schema dump support for native PostgreSQL types. The issue here is that another gem seems to be interacting with postgres_ext. See the issue here: https://github.com/dockyard/postgres_ext/issues/83 – Dan McClain May 25 '13 at 20:35