我在ruby中有一个数据库迁移脚本。
如何在迁移脚本中添加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处
答案 0 :(得分:1)
将where
作为字符串
add_index :hotel_room_types, [:hotel_id, :dynamic_price_from],
unique: true, where: 'status = 1', name: 'by_hotel_id_from'