Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structure.sql created if schema_format = :sql is incorrect if postgres schemas are used. #86

Closed
QuinnHarris opened this issue Feb 25, 2015 · 1 comment

Comments

@QuinnHarris
Copy link

The structure.sql dump file created by the postgres database dump tool does not leave the search_path paramater in a predictable state if the database contains different schemas (other than public). Accordingly the statements to insert the migration rows appended to the structure.sql might not work if the search_path doesn't include the public schema.

This produces the following error

ERROR: relation "schema_migrations" does not exist

The following monkey patch fixes this problem for postgres

module SequelRails
  class Migrations
    class << self
      alias_method :dump_schema_information_orig, :dump_schema_information

      def dump_schema_information(opts = {})
        if opts.fetch :sql
          "SET search_path = public, pg_catalog;\n"
        else
          ''
        end + dump_schema_information_orig(opts)
      end
    end
  end
end
@JonathanTron
Copy link
Member

Thanks for reporting the issue, please test if it works for you so I can release a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants