{"action":"opened","issue":{"url":"https://api.github.com/repos/SchemaPlus/schema_plus/issues/221","labels_url":"https://api.github.com/repos/SchemaPlus/schema_plus/issues/221/labels{/name}","comments_url":"https://api.github.com/repos/SchemaPlus/schema_plus/issues/221/comments","events_url":"https://api.github.com/repos/SchemaPlus/schema_plus/issues/221/events","html_url":"https://github.com/SchemaPlus/schema_plus/issues/221","id":92622444,"number":221,"title":"doesn't work with annotate gem and MySQL and postgres","user":{"login":"dayweek","id":144325,"avatar_url":"https://avatars.githubusercontent.com/u/144325?v=3","gravatar_id":"","url":"https://api.github.com/users/dayweek","html_url":"https://github.com/dayweek","followers_url":"https://api.github.com/users/dayweek/followers","following_url":"https://api.github.com/users/dayweek/following{/other_user}","gists_url":"https://api.github.com/users/dayweek/gists{/gist_id}","starred_url":"https://api.github.com/users/dayweek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dayweek/subscriptions","organizations_url":"https://api.github.com/users/dayweek/orgs","repos_url":"https://api.github.com/users/dayweek/repos","events_url":"https://api.github.com/users/dayweek/events{/privacy}","received_events_url":"https://api.github.com/users/dayweek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-02T12:18:06Z","updated_at":"2015-07-02T12:18:06Z","closed_at":null,"body":"Hi guys, I have this error when I updated schema_plus from 1.8.9 to 2.0.0\r\n\r\nOutput:\r\n```\r\nstark@Tony-Stark ~/Documents/railspool -  $ bundle exec annotate\r\nActiveRecord::ConnectionAdapters::Mysql2Adapter\r\nUnable to annotate app/models/b/foo.rb: undefined method `query' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007f8d7da3fa18>\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/schema_plus_pg_indexes-0.1.4/lib/schema_plus_pg_indexes/middleware/postgresql/schema.rb:39:in `implement'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:53:in `call_implementation'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:85:in `_modware_continue'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:77:in `_modware_call'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:83:in `_modware_continue'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:77:in `_modware_call'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:44:in `execute'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/modware-0.1.2/lib/modware/stack.rb:20:in `start'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/schema_monkey-2.1.0/lib/schema_monkey/stack.rb:34:in `start'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/schema_plus_core-0.5.0/lib/schema_plus/core/active_record/connection_adapters/mysql2_adapter.rb:32:in `indexes'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:216:in `get_index_info'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:193:in `get_schema_info'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:346:in `annotate'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:485:in `annotate_model_file'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:471:in `block in do_annotations'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:470:in `each'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/lib/annotate/annotate_models.rb:470:in `do_annotations'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/gems/annotate-2.6.10/bin/annotate:185:in `<top (required)>'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/bin/annotate:23:in `load'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/bin/annotate:23:in `<main>'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/bin/ruby_executable_hooks:15:in `eval'\r\n\t/Users/stark/.rvm/gems/ruby-2.1.6@pool/bin/ruby_executable_hooks:15:in `<main>'\r\nNothing to annotate.\r\n```\r\n\r\nI have two 2 models: A::Api and B::Foo\r\n\r\nso A::Api model is in app/models/a dir and B::Foo is in app/models/b\r\n\r\nA::Api model\r\n\r\n```\r\nclass A::Api < ActiveRecord::Base\r\nend\r\n```\r\n\r\nB::Foo model\r\n\r\n```\r\nmodule B\r\n  class Foo < Base\r\n    self.table_name = 'foos'\r\n  end\r\nend\r\n```\r\n\r\nAnd there is also B::Base in app/models/b\r\n\r\n```\r\nmodule B\r\n  class Base < ActiveRecord::Base\r\n    self.abstract_class = true\r\n\r\n    def self.establish_connection\r\n      if database_url = MYSQL_DATABASE_URL\r\n        uri = URI.parse(database_url)\r\n        super({\r\n          'adapter' => uri.scheme,\r\n          'database' => uri.path.split('/').last,\r\n          'host' => uri.host,\r\n          'username' => uri.user,\r\n          'password' => uri.password,\r\n          'reconnect' => true\r\n        })\r\n      end\r\n    end\r\n\r\n    establish_connection\r\n  end\r\nend\r\n```\r\n\r\nMYSQL_DATABASE_URL is set in initializer from env var.\r\n\r\nrake task for configuring annotate:\r\n\r\n```\r\n  task :set_annotation_options do\r\n    # Just some example settings from annotate 2.6.0.beta1\r\n    Annotate.set_defaults({\r\n                              'position_in_routes'   => \"before\",\r\n                              'position_in_class'    => \"before\",\r\n                              'position_in_test'     => \"before\",\r\n                              'position_in_fixture'  => \"before\",\r\n                              'position_in_factory'  => \"before\",\r\n                              'show_indexes'         => \"true\", # if false it works\r\n                              'simple_indexes'       => \"false\",\r\n                              'model_dir'            => \"app/models\",\r\n                              'include_version'      => \"false\",\r\n                              'require'              => \"\",\r\n                              'exclude_tests'        => \"true\",\r\n                              'exclude_fixtures'     => \"false\",\r\n                              'exclude_factories'    => \"false\",\r\n                              'ignore_model_sub_dir' => \"false\",\r\n                              'skip_on_db_migrate'   => \"false\",\r\n                              'format_bare'          => \"true\",\r\n                              'format_rdoc'          => \"false\",\r\n                              'format_markdown'      => \"false\",\r\n                              'sort'                 => \"true\",\r\n                              'force'                => \"false\",\r\n                              'trace'                => \"true\",\r\n                          })\r\n  end\r\n```\r\n\r\nBasically A::Api connects to postgres by default (database.yml) and B::Foo connects to MySQL. When I remove schema_plus gem, or downgrade it to 1.8.9 or set show_indexes to false in the task it works. So I assume it is an issue in schema_plus (schema_plus_pg_indexes perhaps?). The order in which the models are annotated is important in order to reproduce this.\r\n\r\nEnvironment:\r\n\r\n```\r\n  * schema_auto_foreign_keys (0.1.0)\r\n  * schema_monkey (2.1.0)\r\n  * schema_plus (2.0.0)\r\n  * schema_plus_columns (0.1.0)\r\n  * schema_plus_core (0.5.0)\r\n  * schema_plus_db_default (0.1.0)\r\n  * schema_plus_default_expr (0.1.0)\r\n  * schema_plus_enums (0.1.0)\r\n  * schema_plus_foreign_keys (0.1.2)\r\n  * schema_plus_indexes (0.2.0)\r\n  * schema_plus_pg_indexes (0.1.4)\r\n  * schema_plus_tables (0.1.0)\r\n  * schema_plus_views (0.2.3)\r\n  * mysql2 (0.3.18)\r\n  * rails (4.2.3)\r\n  * annotate (2.6.10)\r\n  * pg (0.18.2)\r\n```"}}