From ef6f239182e5ded2eebfb577ccd54ce9281859d2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 12 Aug 2014 15:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=88=86=E7=A6=BB=E5=87=BA=E6=9D=A5=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=A1=A8=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2065147_add_colun_to_course_attachments.rb | 5 ++++ ...0140812065417_update_course_attachments.rb | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 db/migrate/20140812065147_add_colun_to_course_attachments.rb create mode 100644 db/migrate/20140812065417_update_course_attachments.rb 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