精品课程数据迁移

This commit is contained in:
huang 2016-01-22 16:46:23 +08:00
parent edd198e91f
commit 2947ff8997
4 changed files with 35 additions and 14 deletions

View File

@ -51,7 +51,7 @@ module ApplicationHelper
# 判断课程是否为精品课程
def is_excellent_course course
course.is_excellent? ? true : false
(course.is_excellent? or course.excellent_option?) ? true : false
end
# 判断课程对成员是否可见

View File

@ -0,0 +1,6 @@
class AddExcellentOptionToCourse < ActiveRecord::Migration
def change
add_column :courses, :excellent_option, :integer, :default => false
end
end

View File

@ -0,0 +1,19 @@
class DefineExcellentOptionCourse < ActiveRecord::Migration
def up
arr = [151,122,15,227,139,410,291,224,55,137,414,43,417,52,205,44,216,132,204,258,411,50,
419,390,420,133,91,112,202,95,194,34,172,403,177,252,138,352,225,46,279,382,397,286,344,27,175,
124,265,88,59,110,72,92,392,413,26,201,94,57,156,393,154,12,262]
for i in 0..arr.length-1
begin
puts arr[i]
course = Course.find(arr[i])
course.update_attribute(:excellent_option, true)
rescue
logger.error("Course is not found!")
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160121070232) do
ActiveRecord::Schema.define(:version => 20160122083507) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -500,6 +500,7 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
t.integer "end_time"
t.string "end_term"
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
end
create_table "custom_fields", :force => true do |t|
@ -1216,7 +1217,6 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
create_table "org_members", :force => true do |t|
t.integer "user_id"
t.integer "organization_id"
t.string "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
@ -1714,10 +1714,6 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
t.string "extra"
end
create_table "temp", :id => false, :force => true do |t|
t.integer "id", :default => 0, :null => false
end
create_table "time_entries", :force => true do |t|
t.integer "project_id", :null => false
t.integer "user_id", :null => false