Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何在sequel中为postgres范围类型编写迁移?_Ruby_Sequel - Fatal编程技术网

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

Ruby 如何在sequel中为postgres范围类型编写迁移?,ruby,sequel,Ruby,Sequel,是否可以在后续迁移中定义postgres范围类型(例如,tsrange)?我在文档中找到了pg_范围扩展,但找不到迁移示例…Sequel将Postgres数据类型作为迁移中的关键字提供。我刚刚为批量折扣计划表做了一个示例,其中有一个限制,禁止同一产品组的重叠范围: create_table(:product_group_bulk_discounts) do primary_key :id foreign_key :product_group_id, :product_groups, :o

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

Sequel将Postgres数据类型作为迁移中的关键字提供。我刚刚为批量折扣计划表做了一个示例,其中有一个限制,禁止同一产品组的重叠范围:

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
注意:这种类型的排除约束要求在数据库上加载btree_gist扩展