添加时间迁移
This commit is contained in:
parent
311634abf1
commit
6dff29f931
|
@ -0,0 +1,26 @@
|
|||
class UpdateMemoTime < ActiveRecord::Migration
|
||||
def up
|
||||
memo_count = Memo.all.count / 30 + 1
|
||||
transaction do
|
||||
for i in 1 ... memo_count do i
|
||||
MemoMessage.page(i).per(30).each do |memo_message|
|
||||
if memo_message.memo
|
||||
if memo_message.memo.respond_to?("created_at")
|
||||
memo_message.created_at = memo_message.memo.created_at
|
||||
elsif memo_message.memo.respond_to?("created_on")
|
||||
memo_message.created_at = memo_message.memo.created_on
|
||||
end
|
||||
memo_message.save
|
||||
|
||||
memo_messages = MemoMessage.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first
|
||||
memo_messages.created_at = memo_message.created_at
|
||||
memo_messages.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
class UpdateUserfeedbackTime < ActiveRecord::Migration
|
||||
def up
|
||||
user_feedback_count = UserFeedbackMessage.all.count / 30 + 1
|
||||
transaction do
|
||||
for i in 1 ... user_feedback_count do i
|
||||
UserFeedbackMessage.page(i).per(30).each do |ufm|
|
||||
if ufm.course_message
|
||||
if ufm.course_message.respond_to?("created_at")
|
||||
ufm.created_at = ufm.course_message.created_at
|
||||
elsif ufm.course_message.respond_to?("created_on")
|
||||
ufm.created_at = ufm.course_message.created_on
|
||||
end
|
||||
ufm.save
|
||||
|
||||
user_feedbach_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first
|
||||
user_feedbach_messages.created_at = ufm.created_at
|
||||
user_feedbach_messages.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
# encoding: UTF-8
|
||||
class UserFeedbackMessage < ActiveRecord::Migration
|
||||
class AboutUserFeedbackMessage < ActiveRecord::Migration
|
||||
def up
|
||||
JournalsForMessage.all.each do |jour_for_message|
|
||||
transaction do
|
||||
|
@ -23,6 +22,7 @@ class UserFeedbackMessage < ActiveRecord::Migration
|
|||
end
|
||||
unless receivers.blank?
|
||||
receivers.each do |r|
|
||||
puts jour_for_message.id
|
||||
jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => false)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue