socialforge/db/migrate/20140812065417_update_cours...

30 lines
1.1 KiB
Ruby

class UpdateCourseAttachments < ActiveRecord::Migration
def up
attachments = Attachment.where(" container_type = 'Course'")
attachments.each do |attachment|
course_attachment = CourseAttachment.new
course_attachment.container_id = attachment.container_id
course_attachment.filename = attachment.filename
course_attachment.disk_filename = attachment.disk_filename
course_attachment.filesize = attachment.filesize
course_attachment.content_type = attachment.content_type
course_attachment.digest = attachment.digest
course_attachment.downloads = attachment.downloads
course_attachment.author_id = attachment.author_id
course_attachment.created_at = attachment.created_on
course_attachment.description = attachment.description
course_attachment.disk_directory = attachment.disk_directory
course_attachment.attachtype = attachment.attachtype
course_attachment.is_public = attachment.is_public
course_attachment.save(:validate => false)
end
end
def down
coll = CourseAttachment.all
coll.each do |model|
model.destroy
end
end
end