projects
Three new constraints in Sexy PG Constraints
I just added three more constraints. Finally the package feels complete.
New constraints
odd even format
The :format constraint allows you to pass your own regular expression for matching! This is intended to accompany validates_format_of in ActiveRecord.
The other two are pretty self explanatory.
It’s already pretty easy to add your own constraints to the package (just extend constraints module with more [...]
Sexy PG Constraints now supports foreign key and mutlicolumn constraints
The title sums it up pretty much. Now you can do things like following.
class AddConstraintsToBooks < ActiveRecord::Migration def self.up constrain :books do |t| t[:title, :author_id].all :unique => true # Notice how multiple columns are listed in brackets. end end
def self.down deconstrain :books do |t| t[:title, :author_id].all :unique [...]
Sexy PG Constraints
If you’re on PostgreSQL and see the importance of data-layer constraints – this gem/plugin is for you. It integrates constraints into PostgreSQL adapter so you can add/remove them in your migrations. You get two simple methods for adding/removing constraints, as well as a pack of pre-made constraints.
The repository is at http://github.com/maxim/sexy_pg_constraints
Install
As a gem
gem install maxim-sexy_pg_constraints [...]