续集中的复杂约束

时间:2015-12-05 20:05:53

标签: ruby sequel

我在Sequel migratin中有以下约束:

constraint(:date_is_1_feb_or_1_aug, 'EXTRACT(MONTH FROM date)::INT IN (2,8) AND EXTRACT(DAY FROM date)::INT = 1')

有没有办法简化这个并使用DSL?

1 个答案:

答案 0 :(得分:1)

constraint(:date_is_1_feb_or_1_aug,
   Sequel.extract(:month, :date).cast(Integer)=>[2,8],
   Sequel.extract(:day, :date).cast(Integer)=>1)