rake db:test:clone_structure might fail with multiple schemas in postgres

Hi guys.

I'm having problems when trying to run tests of a rails 3 application
with multiple schemas in postgres.

The thing is that 'rake db:test:clone_structure' fails when tries to
insert migration versions into 'schema_migrations' table. This is
because after all the schemas are dumped, the search path might be set
to a schema other than the 'public' and the schema_migrations table is
not found.

I'm not sure about the order in which postgres schemas are dumped
(alphabetical?) but I think the problem appears when there are schemas
alphabetically superior to 'public' (e.g: 'z_schema_name'), assuming
schema_migrations table is in the 'public' schema. Anyway, I created a
pull request that explains how to reproduce this issue with a few


I would appreciate if someone can take a look at it to know if there
is something I missing.