Activerecord-jdbc-adapter: Rake 'drop' task fails with PostgreSQL
-----------------------------------------------------------------
Key: JRUBY-5081
URL: http://jira.codehaus.org/browse/JRUBY-5081
Project: JRuby
Issue Type: Bug
Components: JRuby-extras
Reporter: Scott Lowe
Priority: Minor
This issue affects the JDBC rake tasks that call the :drop task, i.e. db:reset,
db:drop
The root cause is that PostgreSQL does not allow a database to be dropped
whilst there
is a connection to it.
http://www.postgresql.org/docs/8.4/interactive/sql-dropdatabase.html
The issue manifests itself around line 35 in the jdbc.rake file:
http://github.com/nicksieger/activerecord-jdbc-adapter/blob/master/lib/arjdbc/jdbc/jdbc.rake
redefine_task :drop => :environment do
config = ActiveRecord::Base.configurations[rails_env]
begin
ActiveRecord::Base.establish_connection(config)
db = ActiveRecord::Base.connection.database_name
ActiveRecord::Base.connection.drop_database(db)
rescue
drop_database(config.merge('adapter' => config['adapter'].sub(/^jdbc/, '')))
end
end
The issue can be fixed by establishing a connection to the 'postgres' database
in
order to drop the development/test/other database. This appears to be the
approach taken
in the db:test:purge task where "config['database']" is set to "postgres".
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email