diff options
author | ian <iwarshak@stripey.net> | 2008-06-16 17:45:50 -0500 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-22 18:31:47 -0700 |
commit | 3532eaf92a96b87fb422625142ff0efa1cac17ab (patch) | |
tree | ab5cd93b583a79098d675217ab691b498cb9502c /activerecord | |
parent | f94600bdaf7d73971ad9a53148b0844c2efb901d (diff) | |
download | rails-3532eaf92a96b87fb422625142ff0efa1cac17ab.tar.gz rails-3532eaf92a96b87fb422625142ff0efa1cac17ab.tar.bz2 rails-3532eaf92a96b87fb422625142ff0efa1cac17ab.zip |
Only use DROP ... IF EXISTS for PostgreSQL 8.2 or later. [#400 state:resolved]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 294f4c1929..d0585d52ac 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -553,7 +553,15 @@ module ActiveRecord # 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 |