In my Rails structure.sql
, I have this line of code:
CREATE UNIQUE INDEX primary_active_fruit_in_season_constraint ON trees USING btree (user_id) WHERE (is_ripe AND is_in_season);
I no longer need this validation so I am going to remove the validation in the Rails code on the Tree
model. But how to I remove this database validation? Where did it come from? What line of code in a rails migration created this? How do I remove it?
We have no way of knowing who created that index but the
WHERE
clause attached to it suggests (since AR generally doesn't know about such advanced things) that it was created manually with something like:and you can drop the index in a migration the same way:
Manually create a migration file with those two methods in it and
rake db:migrate
as usual.