diff --git a/db/migrate/20140812065147_add_colun_to_course_attachments.rb b/db/migrate/20140812065147_add_colun_to_course_attachments.rb new file mode 100644 index 000000000..75ea0b757 --- /dev/null +++ b/db/migrate/20140812065147_add_colun_to_course_attachments.rb @@ -0,0 +1,5 @@ +class AddColunToCourseAttachments < ActiveRecord::Migration + def change + add_column :course_attachments, :container_id, :integer, :default => 0 + end +end diff --git a/db/migrate/20140812065417_update_course_attachments.rb b/db/migrate/20140812065417_update_course_attachments.rb new file mode 100644 index 000000000..f14accb48 --- /dev/null +++ b/db/migrate/20140812065417_update_course_attachments.rb @@ -0,0 +1,29 @@ +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