rails/rails — pull request #11455 by antonio (2013-07-16 06:55:03+00:00)
Title: Define enable_extension method to prevent undefined method error

I am getting this error when trying to run `rake db:test:prepare` in my application. The problem seems to be that I am using postgresql for development but sqlite3 for testing, and the method `enable_extension` is not defined in `Sqlite3Adapter` nor `AbstractAdapter`. As the schema is dumped from the dev database, the following code in `PostgresqlAdapter` (line 70)

`
def extensions(stream)
return unless @connection.supports_extensions?
extensions = @connection.extensions
if extensions.any?
stream.puts " # These are extensions that must be enabled in order to support this database"
extensions.each do |extension|
stream.puts " enable_extension #{extension.inspect}"
end
stream.puts
end
end
`

will always write the line

`enable_extension "plpgsql"`

in `schema.rb`

This patch simply adds an empty definition to prevent it. Another option to fix this would be to modify the schema dumper to write `enable_extension("plpgsql") if supports_extensions?` instead. I can adapt the pull request to this if needed.

I am not sure if this is intended or I am missing something, please let me know if there is a smarter way to fix it (or no need to fix it at all!). Also I am not sure what to test here, can someone point me in the right direction? Should I also modify the changelog?