pinnymz / migration_comments

Comments for your migrations
MIT License
173 stars 31 forks source link

Fix: schema_dumper.rb stops on schema errors #7

Closed crosspath closed 11 years ago

crosspath commented 11 years ago

I've got message "# Could not dump table "places_groups" because of following StandardError" because I use enum types in DB. In PostgreSQL it is custom type. ActiveRecord (activerecord (3.2.9)) cannot dump it and send this message. It is normal for me. But migration_comments gem stops rake:db:migrate if schema file contains error message (starting with '#'). This fix will tell schema_dumper.tb to ignore error messages.

pinnymz commented 11 years ago

Thanks for the input. Can you provide a test case, or an example of a migration using a custom type that throws this error?

crosspath commented 11 years ago

Migration: execute "DROP TYPE IF EXISTS places_groups_metatype; CREATE TYPE places_groups_metatype AS ENUM('physical', 'virtual');" execute "ALTER TABLE places_groups ALTER COLUMN metatype TYPE places_groups_metatype USING 'physical';"

Schema: # Could not dump table "places_groups" because of following StandardError # Unknown type 'places_groups_metatype' for column 'metatype'

AFAIK Rails 3 doesn't support enum types.

pinnymz commented 11 years ago

Ok, I see the problem. However, since the SchemaDumper doesn't know how to output the table, it seems rather odd to add comments to this table (or its columns) since they will not be reflected in the schema.rb, and thus won't be added to new systems that are built from schema.rb. Are you aware of this issue?

Note that adding comments to the other tables that the SchemaDumper can render work properly and are not affected by this issue.

pinnymz commented 11 years ago

I've added a testcase and error-output detection to work around this - thanks again for letting me know.