High Performance PostgreSQL for Rails: wrong migration code sample (page 115)

@andatki

class AddTripRatingCheckConstraint < ActiveRecord::Migration[7.0]
  def change
    add_check_constraint :users, "rating >= 1 AND rating <= 5",
                                 name: "rating_check"
  end
end

add_check_constraint :users, should be add_check_constraint :trips,

1 Like

Great catch. The rating column is on the “trips” table, so the constraint should be added to that table and not “users.” We will get this fixed up! Thank you for submitting it.

This was fixed, thank you!