Home

Awesome

Gem Version Build Status Coverage Status

SchemaPlus::Enums

SchemaPlus::Enums provides support for enum data types in ActiveRecord. Currently the support is limited to defining enum data types, for PostgreSQL only.

SchemaPlus::Enums is part of the SchemaPlus family of Ruby on Rails ActiveRecord extension gems.

Installation

<!-- SCHEMA_DEV: TEMPLATE INSTALLATION - begin --> <!-- These lines are auto-inserted from a schema_dev template -->

As usual:

gem "schema_plus_enums"                # in a Gemfile
gem.add_dependency "schema_plus_enums" # in a .gemspec
<!-- SCHEMA_DEV: TEMPLATE INSTALLATION - end -->

Compatibility

SchemaPlus::Enums is tested on:

<!-- SCHEMA_DEV: MATRIX - begin --> <!-- These lines are auto-generated by schema_dev based on schema_dev.yml --> <!-- SCHEMA_DEV: MATRIX - end -->

Usage

In a migration, an enum can be created:

create_enum :color, 'red', 'green', 'blue' # default schema is 'public'
create_enum :color, 'cyan', 'magenta', 'yellow', 'black', schema: 'cmyk'

New values can be added

add_enum_value :color, 'black'
add_enum_value :color, 'red', if_not_exists: true
add_enum_value :color, 'purple', after: 'red'
add_enum_value :color, 'pink', before: 'purple'
add_enum_value :color, 'white', schema: 'cmyk'

Values can be dropped

remove_enum_value :color, 'black'
remove_enum_value :color, 'black', schema: 'cmyk'

Values can be renamed

rename_enum_value :color, 'red', 'orange'
rename_enum_value :color, 'red', 'orange', schema: 'cmyk'

The enum can be renamed

rename_enum :color, :hue
rename_enum :color, :hue, schema: 'cmyk'

And can be dropped:

drop_enum :color
drop_enum :color, schema: 'cmyk'

Release Notes

Development & Testing

Are you interested in contributing to SchemaPlus::Enums? 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: TEMPLATE USES SCHEMA_DEV - begin --> <!-- These lines are auto-inserted from a schema_dev template --> <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end --> <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin --> <!-- These lines are auto-inserted from a schema_dev template --> <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - end --> <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_MONKEY - begin --> <!-- These lines are auto-inserted from a schema_dev template --> <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_MONKEY - end -->