[![Gem Version](https://badge.fury.io/rb/schema_plus_compatibility.svg)](http://badge.fury.io/rb/schema_plus_compatibility) [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_compatibility.svg)](http://travis-ci.org/SchemaPlus/schema_plus_compatibility) [![Coverage Status](https://coveralls.io/repos/github/SchemaPlus/schema_plus_compatibility/badge.svg?branch=master)](https://coveralls.io/github/SchemaPlus/schema_plus_compatibility?branch=master) # SchemaPlus::Compatibility SchemaPlus::Compatibility provides compatibility support for developing and testing using different versions of ActiveRecord. SchemaPlus::Compatibility is part of the [SchemaPlus](https://github.com/SchemaPlus/) family of Ruby on Rails ActiveRecord extension gems. ## Installation As usual: ```ruby gem "schema_plus_compatibility" # in a Gemfile gem.add_dependency "schema_plus_compatibility" # in a .gemspec ``` ## Usage SchemaPlus::Compatibility provides the following new methods: * `connection.tables_only` In AR 5.0, `connection.tables` is deprecated for some db adapters, and in AR 4.2 it may actually returns views (if any are defined) as well. This method consistently returns just tables regardless of the ActiveRecord version. * `connection.user_tables_only` In AR 5.0, an internal table (`ActiveRecord::InternalMetadata.table_name`) is added by ActiveRecord. The existence of this table trips up some tests (and possibly real code) which doesn't expect to see it. This method returns all tables except the internal metadata table. * `Migration.latest_version` In AR 5.0, `ActiveRecord::Migration` is versioned using `[]`; in AR 4.2 it's not versioned, making it awkward to create migrations cross-version. This method returns the latest migration version in both AR 4.2 and AR 5.0. Note that the methods provided by SchemaPlus::Compatibility are subject to arbitrary change if/when SchemaPlus supports new versions of AR and/or drops support for old versions. But SchemaPlus::Compatibility will of course follow semantic versioning. ## Compatibility SchemaPlus::Compatibility is tested on: * ruby **2.3.1** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql** * ruby **2.3.1** with activerecord **5.0**, using **mysql2**, **sqlite3** or **postgresql** ## History * 0.2.0 - replace the ill-defined `connection.tables_without_deprecation` with `connection.tables_only` which truly returns solely tables. * 0.1.0 - Initial release ## Development & Testing Are you interested in contributing to SchemaPlus::Compatibility? Thanks! Please follow the standard protocol: fork, feature branch, develop, push, and issue pull request. Some things to know about to help you develop and test: * **schema_dev**: SchemaPlus::Compatibility uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to facilitate running rspec tests on the matrix of ruby, activerecord, and database versions that the gem supports, both locally and on [travis-ci](http://travis-ci.org/SchemaPlus/schema_plus_compatibility) To to run rspec locally on the full matrix, do: $ schema_dev bundle install $ schema_dev rspec You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README. The matrix of configurations is specified in `schema_dev.yml` in the project root. * **schema_monkey**: SchemaPlus::Compatibility is implemented as a [schema_monkey](https://github.com/SchemaPlus/schema_monkey) client, using [schema_monkey](https://github.com/SchemaPlus/schema_monkey)'s convention-based protocols for extending ActiveRecord and using middleware stacks.