清理课程状态表,修正同一课程出现多次的BUG
This commit is contained in:
parent
ff8994fc9d
commit
864ef17941
|
@ -1,3 +1,7 @@
|
||||||
class CourseStatus < ActiveRecord::Base
|
class CourseStatus < ActiveRecord::Base
|
||||||
attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count
|
attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count
|
||||||
|
|
||||||
|
belongs_to :course
|
||||||
|
validates_presence_of :course_id
|
||||||
|
validates_uniqueness_of :course_id
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ class StoredCourseProcedure < ActiveRecord::Migration
|
||||||
courseStatus.watchers_count = projectstatus.watchers_count
|
courseStatus.watchers_count = projectstatus.watchers_count
|
||||||
courseStatus.grade = projectstatus.grade
|
courseStatus.grade = projectstatus.grade
|
||||||
courseStatus.course_ac_para = projectstatus.course_ac_para
|
courseStatus.course_ac_para = projectstatus.course_ac_para
|
||||||
courseStatus.save(:validate => false)
|
courseStatus.save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
class ClearCourseStatus < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
# 删除重复的课程状态
|
||||||
|
# 之前做迁移的时候未加验证可能引起此问题
|
||||||
|
courseidlist = "(-1"
|
||||||
|
CourseStatus.all.each do |status|
|
||||||
|
sql = "delete from course_statuses where course_id=" + status.course_id.to_s + " and id<>" + status.id.to_s +
|
||||||
|
" and course_id not in " +courseidlist + ")"
|
||||||
|
courseidlist += "," + status.course_id.to_s;
|
||||||
|
execute(sql)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
24
db/schema.rb
24
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140703085204) do
|
ActiveRecord::Schema.define(:version => 20140704034832) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -794,20 +794,20 @@ ActiveRecord::Schema.define(:version => 20140703085204) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "relative_memos", :force => true do |t|
|
create_table "relative_memos", :force => true do |t|
|
||||||
t.integer "osp_id", :null => false
|
t.integer "osp_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :null => false
|
t.text "content", :limit => 16777215, :null => false
|
||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.integer "replies_count", :default => 0
|
t.integer "replies_count", :default => 0
|
||||||
t.integer "last_reply_id"
|
t.integer "last_reply_id"
|
||||||
t.boolean "lock", :default => false
|
t.boolean "lock", :default => false
|
||||||
t.boolean "sticky", :default => false
|
t.boolean "sticky", :default => false
|
||||||
t.boolean "is_quote", :default => false
|
t.boolean "is_quote", :default => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "viewed_count_crawl", :default => 0
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
t.integer "viewed_count_local", :default => 0
|
t.integer "viewed_count_local", :default => 0
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.string "userhomeurl"
|
t.string "userhomeurl"
|
||||||
|
|
Loading…
Reference in New Issue