Sha256: e9be55f6175b6b31dbb0da928ba2ab5f7d5e4482688f29698243a149b32be3d4
Contents?: true
Size: 351 Bytes
Versions: 1
Compression:
Stored size: 351 Bytes
Contents
module RC module Inclusion def add_inclusion_constraint(table, attribute, options = {}) name = "#{table}_#{attribute}" values = options[:in].map {|x| "'#{x}'" }.join(", ") conditions = "#{attribute} IN (#{values})" execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rein-0.3.0 | lib/rein/constraint/inclusion.rb |