Git Product home page Git Product logo

schema_plus_pg_types's Introduction

Gem Version Build Status Coverage Status Dependency Status

SchemaPlus::PgTypes

SchemaPlus::PgTypes adds better support for PostgreSQL-specific types to ActiveRecord, mapping them to higher-level types instead of raw strings. Currently this only includes the PostgreSQL interval type, which is mapped to ActiveSupport::Duration.

Installation

As usual:

gem "schema_plus_pg_types"                # in a Gemfile
gem.add_dependency "schema_plus_pg_types" # in a .gemspec

Compatibility

SchemaPlus::PgTypes is tested on:

  • ruby 2.3.1 with activerecord 5.0, using postgresql

Usage

This gem adds a little more syntactic sugar for defining PostgreSQL types in your migrations. You can now simply write:

create_table :events do |t|
  t.interval :event_duration
end

Instead of:

create_table :events do |t|
  t.column :event_duration, :interval
end

The event_duration column will be represented as ActiveSupport::Duration in your model, so you should be able to use it without the usual fuss:

long_events = Event.where(1.hours..10.hours)

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

History

  • 0.1.1 - Improve test coverage (no change to production code)
  • 0.1.0 - Initial release

Development & Testing

Are you interested in contributing to SchemaPlus::PgTypes? 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::PgTypes uses 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

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

    The matrix of configurations is specified in schema_dev.yml in the project root.

  • schema_plus_core: SchemaPlus::PgTypes uses the SchemaPlus::Core API that provides middleware callback stacks to make it easy to extend ActiveRecord's behavior. If that API is missing something you need for your contribution, please head over to schema_plus_core and open an issue or pull request.
  • schema_monkey: SchemaPlus::PgTypes is implemented as a schema_monkey client, using schema_monkey's convention-based protocols for extending ActiveRecord and using middleware stacks.

schema_plus_pg_types's People

Contributors

boazy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.