Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.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 on rails 创建索引时添加where子句_Ruby On Rails_Postgresql - Fatal编程技术网

Ruby on rails 创建索引时添加where子句

Ruby on rails 创建索引时添加where子句,ruby-on-rails,postgresql,Ruby On Rails,Postgresql,我有一个ruby中的DB迁移脚本 如何在迁移脚本中添加where子句 unless index_exists?(:hotel_room_types, [:hotel_id, :dynamic_price_from]) add_index :hotel_room_types, [:hotel_id, :dynamic_price_from], unique: true, where: (status =1), name: 'by_hotel_id_from' end

我有一个ruby中的DB迁移脚本

如何在迁移脚本中添加where子句

unless index_exists?(:hotel_room_types, [:hotel_id, :dynamic_price_from])
      add_index :hotel_room_types, [:hotel_id, :dynamic_price_from], 
      unique: true, where: (status =1), name: 'by_hotel_id_from'
 end

PG::DatatypeMismatch: ERROR:  argument of WHERE must be type boolean, not type integer

第1行:…otel_room_types”(“hotel_id”,“dynamic_price_from”),其中1将
WHERE作为字符串

add_index :hotel_room_types, [:hotel_id, :dynamic_price_from], 
  unique: true, where: 'status = 1', name: 'by_hotel_id_from'