Permalink
Browse files

Only use DROP ... IF EXISTS for PostgreSQL 8.2 or later. [#400 state:…

…resolved]
  • Loading branch information...
iwarshak authored and jeremy committed Jun 16, 2008
1 parent f94600b commit 3532eaf92a96b87fb422625142ff0efa1cac17ab
Showing with 9 additions and 1 deletion.
  1. +9 −1 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -553,7 +553,15 @@ def create_database(name, options = {})
# Example:
# drop_database 'matt_development'
def drop_database(name) #:nodoc:
- execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
+ if postgresql_version >= 80200
+ execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
+ else
+ begin
+ execute "DROP DATABASE #{quote_table_name(name)}"
+ rescue ActiveRecord::StatementInvalid
+ @logger.warn "#{name} database doesn't exist." if @logger
+ end
+ end
end

0 comments on commit 3532eaf

Please sign in to comment.