All Projects → fnando → ar-check

fnando / ar-check

Licence: MIT license
Enable PostgreSQL's CHECK constraints on ActiveRecord migrations

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to ar-check

mv-core
Migration Validators project core classes
Stars: ✭ 23 (+35.29%)
Mutual labels:  activerecord, constraints
Rein
Database constraints made easy for ActiveRecord.
Stars: ✭ 657 (+3764.71%)
Mutual labels:  activerecord, constraints
AlamoRecord
An elegant yet powerful iOS networking layer inspired by ActiveRecord.
Stars: ✭ 18 (+5.88%)
Mutual labels:  activerecord
wwlayout
Swifty DSL for programmatic Auto Layout in iOS
Stars: ✭ 46 (+170.59%)
Mutual labels:  constraints
models stats
Charts for your rails models with MetricsGraphics.js and NVD3
Stars: ✭ 43 (+152.94%)
Mutual labels:  activerecord
rails async migrations
Asynchronous support for ActiveRecord::Migration
Stars: ✭ 56 (+229.41%)
Mutual labels:  activerecord
computed model
Batch loader with dependency resolution and computed fields
Stars: ✭ 22 (+29.41%)
Mutual labels:  activerecord
ar-variation
Variation behavior for ActiveRecord
Stars: ✭ 46 (+170.59%)
Mutual labels:  activerecord
datetime-scopes
A plugin for ActiveRecord which adds very helpful methods for querying records over time ranges (weeks/days/months/years), and it also respects time-zones!
Stars: ✭ 14 (-17.65%)
Mutual labels:  activerecord
filedb
ActiveRecord for static data definitions based on files
Stars: ✭ 72 (+323.53%)
Mutual labels:  activerecord
ar-dynattribute
Provide ActiveRecord dynamic attributes stored into the single field in serialized state
Stars: ✭ 43 (+152.94%)
Mutual labels:  activerecord
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (+23.53%)
Mutual labels:  activerecord
rails-countries
Integration between Rails and countries gem.
Stars: ✭ 17 (+0%)
Mutual labels:  activerecord
defaults
Add default value for ActiveRecord attributes
Stars: ✭ 16 (-5.88%)
Mutual labels:  activerecord
SimpleCurd
2个类,实现类ActiveRecord,无需写Mapper, mybatis增强
Stars: ✭ 14 (-17.65%)
Mutual labels:  activerecord
ActiveRecord
New Active Record for KumbiaPHP
Stars: ✭ 23 (+35.29%)
Mutual labels:  activerecord
zen-query
parascope gem for param-based scope generation
Stars: ✭ 25 (+47.06%)
Mutual labels:  activerecord
wp-activerecord
An ActiveRecord implementation for WordPress
Stars: ✭ 19 (+11.76%)
Mutual labels:  activerecord
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (+64.71%)
Mutual labels:  activerecord
active-persistence
Active Persistence is a implementation of Active Record Query Interface for JPA that makes it easy and fun.
Stars: ✭ 14 (-17.65%)
Mutual labels:  activerecord

AR::Check

Tests Code Climate Gem Gem

Enable PostgreSQL's CHECK constraints on ActiveRecord migrations.

Installation

Add this line to your application's Gemfile:

gem "ar-check"

And then execute:

$ bundle

Or install it yourself as:

$ gem install ar-check

Usage

To create a CHECK constraint, just use the method add_check.

create_table :employees do |t|
  t.integer :salary, null: false
end

add_check :employees, :positive_salary, "salary > 0"

This will generate a new constraint using the following SQL statement:

ALTER TABLE employees
ADD CONSTRAINT positive_salary_on_things
CHECK (salary > 0)

To remove it, just using remove_check.

remove_check :employees, :positive_salary

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/ar-check. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].