This wrapper gem is no longer being updated. Please use the individual gems for the functionality you need.
The SchemaPlus family of gems provide various extensions and enhancements to ActiveRecord >= 4.2. There are two varieties:
Gems that provide new default automatic behavior
These gems run with the spirit of DRY and convention over configuration -- and automatically take care of things for you. Just include any of these gems and they'll get to work.
Gem Description schema_associations DRY up your models! Why manually define associations (and their inverses) in the models, when you've already defined those relations in the database? schema_auto_foreign_keys DRY up your migrations! It goes without saying that a foreign key relationship should have a foreign key constraint -- it should also go without typing. schema_validations DRY up your validations! The database has constraints in it, your models should automatically validate based on those constraints.
Gems that extend ActiveRecord's feature set
These gems provide new features and capabilities to ActiveRecord that you may wish to take advantage of. None of these have default automagic; once you include the gem the new features are available, but you need to invoke them to use them.
Gem Description schema_plus_columns Column attributes including
ActiveRecord::DB_DEFAULTto set an attribute to the database default
schema_plus_default_expr Use SQL expressions for database default values schema_plus_enums Define enum types in migrations schema_plus_foreign_keys Extended support for foreign keys, including creation as column options,
:deferrable, and SQLite3 support
schema_plus_indexes Convenience and consistency in using indexes schema_plus_multischema Support for using multiple PostgreSQL schemas in a single database schema_plus_pg_indexes PostgreSQL index features:
schema_plus_tables Convenience and consistency in using tables schema_plus_views Create and drop views in migrations
See detailed documentation in each gem's README.
Is there some other capability you wish SchemaPlus had a gem for? Open an issue here. Or try implementing it yourself -- creating ActiveRecord extensions is easy and fun using SchemaPlus's tools schema_monkey and schema_plus_core!!
schema_plus gem (v2.0) is a wrapper that pulls in a collection of gems from the SchemaPlus family. For the most part we recommend skipping this gem and directly including the specific feature gems you're interested in using.
This wrapper is mostly provided for easy upgrade for those who were using schema_plus v1.8, which was a single monolothic gem. This wrapper pulls in the gems that provide the same set of features and automatic behavior as the previous version:
Note that the earlier version (1.x) supports earlier versions of ActiveRecord: 3.1, 4.0, 4.1, and 4.2.0. For more info about that version, see the schema_plus 1.x branch README.
schema_plus 2.0 intends to be a completely backwards-compatible drop-in replacement for SchemaPlus 1.8.x, through restricted to ActiveRecord >= 4.2 and Ruby >= 2.1
If you find any incompatibilities, please report an issue!
In cases where ActiveRecord 4.2 has introduced features previously supported only by SchemaPlus, but using different names, the SchemaPlus 2.0 family of gems now issue deprecation warnings in favor of the rails form. The complete list of deprecations:
Index definition deprecates these options:
drop_tabledeprecates this option:
Foreign key definitions deprecate options to
remove_foreign_keydeprecate the method signature:
(from_table, columns, to_table, primary_keys, options)=>
(from_table, to_table, options)
#table_namein favor of
#column_namesin favor of
#references_column_namesin favor of
#references_table_name in favor of#to_table`
#conditionsin favor of
#kindin favor of
SchemaPlus 2.x is tested against all combinations of:
- ruby 2.1.5 with activerecord 4.2.0, using mysql2, sqlite3 or postgresql
- ruby 2.1.5 with activerecord 4.2.1, using mysql2, sqlite3 or postgresql
Install from http://rubygems.org via
$ gem install "schema_plus"
or in a Gemfile
See CHANGELOG for per-version release notes.
SchemaPlus was originally derived from several "Red Hill On Rails" plugins created by @harukizaemon
And lots of contributors since then.
In 2015, the monolithic schema_plus gem was split into the SchemaPlus family of specific feature gems.