合并两个相同的作业
This commit is contained in:
parent
d232a5241e
commit
77d713a390
|
@ -0,0 +1,20 @@
|
|||
class MergeTwoHomeworks < ActiveRecord::Migration
|
||||
def up
|
||||
student_works = StudentWork.where("homework_common_id = 3387 and user_id in (11256, 11259, 11252, 11499)")
|
||||
unless student_works.nil?
|
||||
student_works.each do |work|
|
||||
work.update_column('homework_common_id', 3463)
|
||||
end
|
||||
end
|
||||
homework = HomeworkCommon.find 3387
|
||||
homework.destroy if homework
|
||||
stu_works = StudentWork.where("homework_common_id = 3387")
|
||||
stu_work_ids = stu_works.empty? ? "(-1)" : "(" + stu_works.map{|work| work.id}.join(',') + ")"
|
||||
stu_work_tests = StudentWorkTest.where("student_work_id in #{stu_work_ids}")
|
||||
stu_work_tests.destroy_all if stu_work_tests
|
||||
stu_works.destroy_all if stu_works
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
19
db/schema.rb
19
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160509025404) do
|
||||
ActiveRecord::Schema.define(:version => 20160511055221) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1107,23 +1107,6 @@ ActiveRecord::Schema.define(:version => 20160509025404) do
|
|||
t.integer "viewed_count", :default => 0
|
||||
end
|
||||
|
||||
create_table "mess", :id => false, :force => true do |t|
|
||||
t.string "课程名"
|
||||
t.integer "课程ID", :default => 0, :null => false
|
||||
t.string "教师姓", :default => "", :null => false
|
||||
t.string "教师名", :limit => 30, :default => "", :null => false
|
||||
t.string "主贴名", :default => "", :null => false
|
||||
t.integer "主贴或回帖ID", :default => 0, :null => false
|
||||
t.integer "回帖对应主贴ID"
|
||||
t.integer "帖子点赞数"
|
||||
t.integer "主贴回复数", :default => 0, :null => false
|
||||
t.text "主贴或回帖内容"
|
||||
t.datetime "发帖时间", :null => false
|
||||
t.integer "发帖或回帖用户ID", :default => 0, :null => false
|
||||
t.string "发帖或回帖用户姓", :default => "", :null => false
|
||||
t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false
|
||||
end
|
||||
|
||||
create_table "message_alls", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "message_id"
|
||||
|
|
Loading…
Reference in New Issue