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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With