Ruby on rails 创建索引时添加where子句
我有一个ruby中的DB迁移脚本 如何在迁移脚本中添加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
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'