如何为 sequel 中的 postgres 范围类型编写迁移?

How to write a migration for a postgres range type in sequel?

是否可以在 sequel 迁移中定义 postgres 范围类型(​​例如,tsrange)?我在文档中找到了 pg_range 扩展,但找不到示例迁移...

Sequel 使 Postgres 数据类型可用作迁移中的关键字。这是我刚刚为批量折扣计划所做的一个 table,限制是不允许同一产品组的重叠范围:

create_table(:product_group_bulk_discounts) do
  primary_key :id
  foreign_key :product_group_id, :product_groups, :on_delete=>:cascade
  int4range :quantity
  money :unit_cost_delta, :default=>0, :null=>true
  exclude [[:product_group_id, '='], [:quantity, '&&']]
end

N.B.: 这种类型的排除约束需要在数据库上加载 btree_gist 扩展。