New validation causes old migration to fail in Rails

166 Views Asked by At

I added new validation to my model. Now, when I run my migrations on old database dump, I have error in the middle with save()! method with description: Validation failed: User can't be blank.

How can I avoid this problem? The only way is to edit this migration to work with database dumps now?

1

There are 1 best solutions below

2
On BEST ANSWER

Solution found to be simple, just don't use .save method on model, it validates all fields. Instead, use .update.