commit
2a31cc91fe
@ -0,0 +1,9 @@
|
|||||||
|
class DefaultChangeset < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
pss = ProjectScore.where("changeset_num is ?", nil)
|
||||||
|
pss.update_all(:changeset_num => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,32 @@
|
|||||||
|
class UpdateBoardsAttach < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
project_count = Project.all.count / 30 + 2
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... project_count do i
|
||||||
|
Project.page(i).per(30).each do |project|
|
||||||
|
puts project.id
|
||||||
|
if ProjectScore.where("project_id=?", project.id).first.nil?
|
||||||
|
puts "create project ==>#{project.id}"
|
||||||
|
ProjectScore.create(:project_id => project.id, :score => false)
|
||||||
|
end
|
||||||
|
unless project.project_score.nil?
|
||||||
|
# update boards
|
||||||
|
unless project.boards.first.nil?
|
||||||
|
boards_count = project.boards.first.topics.count
|
||||||
|
project.project_score.update_attribute(:board_num, boards_count)
|
||||||
|
end
|
||||||
|
# update attach
|
||||||
|
unless project.attachments.nil?
|
||||||
|
attachments_count = project.attachments.count
|
||||||
|
project.project_score.update_attribute(:attach_num, attachments_count)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue