FIX: Skip callbacks when migrating.

This commit is contained in:
Guo Xiang Tan 2016-12-13 08:57:07 +08:00
parent 98fd77fb6c
commit 303282670f
1 changed files with 4 additions and 4 deletions

View File

@ -6,12 +6,12 @@ class AddUploadsToCategories < ActiveRecord::Migration
transaction do
Category.find_each do |category|
logo_upload = Upload.find_by(url: category.logo_url)
category.uploaded_logo_id = logo_upload.id if logo_upload
background_upload = Upload.find_by(url: category.background_url)
category.uploaded_background_id = background_upload.id if background_upload
category.save!
category.update_columns(
uploaded_logo_id: logo_upload&.id,
uploaded_background_id: background_upload&.id
)
end
end
end