• This repository has been archived on 14/May/2022
  • Stars
    star
    689
  • Rank 65,628 (Top 2 %)
  • Language
    Ruby
  • License
    Other
  • Created almost 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SchemaPlus provides a collection of enhancements and extensions to ActiveRecord

Notice (2022-05-13)

This wrapper gem is no longer being updated. Please use the individual gems for the functionality you need.

SchemaPlus family

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 column.indexes and column.unique?
    schema_plus_db_default Use ActiveRecord::DB_DEFAULT to 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: case_insensitive, expression and operator_class
    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!!


The schema_plus gem

Gem Version Build Status Coverage Status Dependency Status

The 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.

Upgrading from schema_plus 1.8.x

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!

Deprecations

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:

    • :conditions => :where
    • :kind => :using
  • drop_table deprecates this option:

    • cascade: true => force: :cascade
  • Foreign key definitions deprecate options to :on_update and :on_delete:

    • :set_null => :nullify
  • add_foreign_key and remove_foreign_key deprecate the method signature:

    • (from_table, columns, to_table, primary_keys, options) => (from_table, to_table, options)
  • ForeignKeyDefinition deprecates accessors:

    • #table_name in favor of #from_table
    • #column_names in favor of Array.wrap(#column)
    • #references_column_names in favor of #primary_key
    • #references_table_name in favor of #to_table`
  • IndexDefinition deprecates accessors:

    • #conditions in favor of #where
    • #kind in favor of #using.to_s

Compatibility

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

Installation

Install from http://rubygems.org via

$ gem install "schema_plus"

or in a Gemfile

gem "schema_plus"

History

  • See CHANGELOG for per-version release notes.

  • SchemaPlus was originally derived from several "Red Hill On Rails" plugins created by @harukizaemon

  • SchemaPlus was created in 2011 by @mlomnicki and @ronen

  • And lots of contributors since then.

  • In 2015, the monolithic schema_plus gem was split into the SchemaPlus family of specific feature gems.

More Repositories

1

schema_validations

Automatically creates validations basing on the database schema.
Ruby
171
star
2

schema_associations

ActiveRecord extension that automatically (DRY) creates associations based on the schema
Ruby
46
star
3

schema_plus_views

Provides support for creating and dropping views in ActiveRecord migrations. Also support for querying views.
Ruby
29
star
4

schema_plus_pg_indexes

Adds support in ActiveRecord for PostgreSQL index expressions and operator classes, as well as a shorthand for case-insensitive indexes
Ruby
29
star
5

schema_auto_foreign_keys

Ruby
22
star
6

schema_plus_enums

Support for enum data types in ActiveRecord
Ruby
13
star
7

schema_plus_multischema

Extends ActiveRecord with support for using multiple schemas within a single database
Ruby
10
star
8

schema_plus_indexes

Adds shorthands and conveniences to ActiveRecord's handling of indexes
Ruby
8
star
9

schema_plus_core

Provides an internal extension API to ActiveRecord, in the form of middleware-style callback stacks
Ruby
7
star
10

schema_monkey

Provides a module insertion protocol to facilitate adding features to ActiveRecord
Ruby
5
star
11

schema_plus_foreign_keys

Extended support for foreign keys in ActiveRecord
Ruby
4
star
12

schema_plus_tables

Added utility for ActiveRecord's handling of tables
Ruby
4
star
13

schema_dev

Development tools for the SchemaPlus family of gems
Ruby
3
star
14

modware

A middleware library, featuring a simple interface and "callback" style semantics in the middleware stack
Ruby
3
star
15

schema_plus_columns

Adds useful accessors to ActiveRecord's Column object
Ruby
2
star
16

schema_plus_db_default

Ruby
1
star