How to disable validation during a migration


#1

I have a migration I am doing which involves a change in column name
that my model uses for validation.

Part of the migration is changing data in that column, which would
fail the validation, but will pass the new validation.

Is there anyway I can “turn off validation” inside the migration for
the duration of the migration?

I have worked around it… but would be good to know for future ref.

Thanks

Mikel


#2

Mikel wrote:

I have a migration I am doing which involves a change in column name
that my model uses for validation.

Part of the migration is changing data in that column, which would
fail the validation, but will pass the new validation.

Is there anyway I can “turn off validation” inside the migration for
the duration of the migration?

I have worked around it… but would be good to know for future ref.

I’m not sure I understand the question, but you can always say…

whatever.save_with_validation(false)

…to skip validation.

–Al Evans