rubysherpas / paranoia

acts_as_paranoid for Rails 5, 6 and 7
Other
2.89k stars 529 forks source link

Restoring a record does not take into account ActiveRecord validations #285

Open spint opened 8 years ago

spint commented 8 years ago

Since version 2.1.4, (uniqueness) validations checks only non-deleted records. However, restoring a record that violates a Rails uniqueness constraint passes without an error. Shouldn't the validations be considered before saving the restored record to the database?

andrewferk commented 7 years ago

Looks to be the same as #319 and #333 is a proposed fix.

For now, you can enforce the uniqueness at the database by updating your indexes. When you try to restore and it violates the database index, a mysql error should be raised.