Add full support for alternate schemas #219

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

sharplet commented Aug 9, 2012

Currently there seem to be quite a few operations where the schema is not specified, and thus the default schema will be used. So if you specify anything other than the default schema in the database config, errors abound.

Would be good to add full support for this.

Contributor

sharplet commented Aug 9, 2012

Currently there's an issue here when running db:reset, in db:abort_if_pending_migrations. When querying the schema_migrations table, AR doesn't seem to be querying the correct schema; I assume it's querying the default schema, instead of the schema defined in the configuration file.

** Invoke db:reset (first_time)
** Invoke environment (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute environment
** Execute db:reset
** Invoke db:purge (first_time)
** Invoke environment 
** Execute db:purge
** Invoke db:structure:load (first_time)
** Invoke environment 
** Execute db:structure:load
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment 
** Invoke db:load_config 
** Execute db:abort_if_pending_migrations
rake aborted!
ActiveRecord::JDBCError: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.SCHEMA_MIGRATIONS, DRIVER=3.52.95: SELECT schema_migrations.version FROM schema_migrations 
arjdbc/jdbc/RubyJdbcConnection.java:285:in `execute_query'
.../gems/activerecord-jdbc-adapter-1.2.2.2/lib/arjdbc/db2/adapter.rb:141:in `_execute'
.../gems/activerecord-jdbc-adapter-1.2.2.2/lib/arjdbc/jdbc/adapter.rb:211:in `execute'
.../gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
.../gems/activesupport-3.2.7/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
.../gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
.../gems/activerecord-jdbc-adapter-1.2.2.2/lib/arjdbc/jdbc/adapter.rb:211:in `execute'
.../gems/activerecord-jdbc-adapter-1.2.2.2/lib/arjdbc/jdbc/adapter.rb:337:in `select'
.../gems/activerecord-jdbc-adapter-1.2.2.2/lib/arjdbc/jdbc/adapter.rb:251:in `select_rows'
.../gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/database_statements.rb:38:in `select_values'
.../gems/activerecord-3.2.7/lib/active_record/migration.rb:587:in `get_all_versions'
.../gems/activerecord-3.2.7/lib/active_record/migration.rb:745:in `migrated'
.../gems/activerecord-3.2.7/lib/active_record/migration.rb:740:in `pending_migrations'
.../gems/activerecord-3.2.7/lib/active_record/railties/databases.rake:292:in `(root)'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
.../gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1615:in `each'
.../gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
.../gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/adsharp/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
.../gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
.../gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
.../gems/activerecord-3.2.7/lib/active_record/railties/databases.rake:308:in `(root)'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
.../gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1615:in `each'
.../gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
.../gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/adsharp/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
.../gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
.../gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
...Rakefile:31:in `(root)'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
.../gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1615:in `each'
.../gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
.../gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/adsharp/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
.../gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
.../gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
.../gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
.../gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
org/jruby/RubyArray.java:1615:in `each'
.../gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
.../gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
.../gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
.../gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
.../gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
.../gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
.../gems/rake-0.9.2.2/bin/rake:33:in `(root)'
org/jruby/RubyKernel.java:1058:in `load'
.../gems/rake-0.9.2.2/bin/rake:19:in `'
org/jruby/RubyKernel.java:1083:in `eval'
.../bin/ruby_noexec_wrapper:14:in `(root)'
Tasks: TOP => db:abort_if_pending_migrations
Owner

kares commented May 29, 2013

Hey Adam, I really appreciate you looking at this and trying to fix the #218, but I'm going to close this PR :

  • code was "too" invasive - it changed behaviour for all adapters, also there might have been quoting issues
  • also it is no longer "relevant" since I just happened to be refactoring rake tasks heavily to support AR-4.0

I'll explain my concerns on how this might be approached "better" on the related issue.

@kares kares closed this May 29, 2013

Contributor

sharplet commented Jun 1, 2013

Hey @kares, no problem. Thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment