From 0b565b1be00a6bff64e1f69e0b625fd1aa61545f Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 19 Oct 2015 17:34:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E6=9C=89=E8=AF=BE=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E4=BB=B6=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151019085603_update_attachments.rb | 23 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20151019085603_update_attachments.rb diff --git a/db/migrate/20151019085603_update_attachments.rb b/db/migrate/20151019085603_update_attachments.rb new file mode 100644 index 000000000..bd3ec2325 --- /dev/null +++ b/db/migrate/20151019085603_update_attachments.rb @@ -0,0 +1,23 @@ +class UpdateAttachments < ActiveRecord::Migration + def up + count = Attachment.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + Attachment.page(i).per(30).each do |attachment| + if attachment.container_type == 'Course' + course = attachment.course + if course + if course.is_public == 0 && attachment.attachtype == 1 + attachment.is_public = 0 + attachment.save + end + end + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 4a0d2312a..44548ad9c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151014023806) do +ActiveRecord::Schema.define(:version => 20151019085603) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false