Bypass validations during a data only migration to fix validation errors
-
12-11-2019 - |
Question
In rails i have amigration to alter production data to fit new validation rules, There are several things wrong so i have 2 different migrations (they could be one but still two aspects that run separately ) one fails because the other validation is not met and vice versa
the validation is new in the model like
validates_uniqueness_of :job_id , :scope => [:day, :time, :user_id , :overtime, :comments] , :message => "Duplicate Entry, Please check your data"
validates_uniqueness_of :job_id , :scope => [:day, :user_id, :comments] , :message => "Has 2 Entires for same job on same day with same comment"
is one kind that is completely new and the other just changed from 24 to 8 and added the overtime bit
validates_numericality_of :time, :greater_than => 0, :less_than_or_equal_to => 8
validates_numericality_of :overtime, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 16
i tried re ordering the migrations and i got the reverse result.
is there a way other than updating the database first then updating this file to bypass that? or is that what i should be doing?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow