rsim/oracle-enhanced — pull request #128 by troyk (2011-11-22 01:17:05+00:00)
Title: only alias create_database and drop_database if the method is defined

I don't have a way to fully test this, as I do not have an oracle database that I can create/drop, but I needed this change to solve my issue of an app that is using mongoid/mongodb as primary datastore and oracle as a read only resource.

Without this change, rake aborts with the following error

```bash
rake aborted!
undefined method `create_database' for class `Object'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced.rake:34:in `'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/activerecord-oracle_enhanced-adapter.rb:8:in `load'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/activerecord-oracle_enhanced-adapter.rb:8:in `block in '
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/railties-3.1.2/lib/rails/railtie.rb:183:in `call'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/railties-3.1.2/lib/rails/railtie.rb:183:in `block in load_tasks'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/railties-3.1.2/lib/rails/railtie.rb:183:in `each'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/railties-3.1.2/lib/rails/railtie.rb:183:in `load_tasks'
/Users/troy/.rvm/gems/ruby-1.9.2-p0@rails312/gems/railties-3.1.2/lib/rails/engine.rb:396:in `block in load_tasks'
...
```

As an additional note, I think this would cause issues as well with an app that is using anything other than oracle as it's primary db, as they are probably going to want these rake tasks left alone.

So this simple patch, wraps the aliasing and definitions in a condition testing for the existance of create/drop_database, which should result in the exact same functionality that exists today for full blown ActiveRecord rails and no errors for rails not using the ActiveRecord railties, but still using ActiveRecord (like me!).

Thanks, Troy