Show More
Commit Description:
[web] refactor problem description, some styling...
Commit Description:
[web] refactor problem description, some styling
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@179 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
db/migrate/028_refactor_problem_body_to_description.rb
| 33 lines
| 854 B
| text/x-ruby
| RubyLexer
|
|
r92 | class RefactorProblemBodyToDescription < ActiveRecord::Migration | ||
def self.up | ||||
add_column :problems, :description_id, :integer | ||||
Problem.reset_column_information | ||||
Problem.find(:all).each do |problem| | ||||
if problem.body!=nil | ||||
description = Description.new | ||||
description.body = problem.body | ||||
description.markdowned = false | ||||
description.save | ||||
problem.description_id = description.id | ||||
problem.save | ||||
end | ||||
end | ||||
remove_column :problems, :body | ||||
end | ||||
def self.down | ||||
add_column :problems, :body, :text | ||||
Problem.reset_column_information | ||||
Problem.find(:all).each do |problem| | ||||
if problem.description_id != nil | ||||
problem.body = Description.find(problem.description_id).body | ||||
problem.save | ||||
end | ||||
end | ||||
remove_column :problems, :description_id | ||||
end | ||||
end | ||||