精品课程数据迁移

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 def is_excellent_course course
course.is_excellent? ? true : false (course.is_excellent? or course.excellent_option?) ? true : false
end 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. # 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| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -500,6 +500,7 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
t.integer "end_time" t.integer "end_time"
t.string "end_term" t.string "end_term"
t.integer "is_excellent", :default => 0 t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
end end
create_table "custom_fields", :force => true do |t| create_table "custom_fields", :force => true do |t|
@ -1084,14 +1085,14 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
create_table "news", :force => true do |t| create_table "news", :force => true do |t|
t.integer "project_id" t.integer "project_id"
t.string "title", :limit => 60, :default => "", :null => false t.string "title", :limit => 60, :default => "", :null => false
t.string "summary", :default => "" t.string "summary", :default => ""
t.text "description" t.text "description"
t.integer "author_id", :default => 0, :null => false t.integer "author_id", :default => 0, :null => false
t.datetime "created_on" t.datetime "created_on"
t.integer "comments_count", :default => 0, :null => false t.integer "comments_count", :default => 0, :null => false
t.integer "course_id" t.integer "course_id"
t.integer "sticky", :default => 0 t.integer "sticky", :default => 0
t.integer "org_subfield_id" t.integer "org_subfield_id"
end end
@ -1216,7 +1217,6 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
create_table "org_members", :force => true do |t| create_table "org_members", :force => true do |t|
t.integer "user_id" t.integer "user_id"
t.integer "organization_id" t.integer "organization_id"
t.string "role"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
@ -1265,8 +1265,8 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
t.integer "home_id" t.integer "home_id"
t.string "domain" t.string "domain"
t.boolean "is_public" t.boolean "is_public"
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.boolean "allow_guest_download", :default => true t.boolean "allow_guest_download", :default => true
end end
@ -1714,10 +1714,6 @@ ActiveRecord::Schema.define(:version => 20160121070232) do
t.string "extra" t.string "extra"
end 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| create_table "time_entries", :force => true do |t|
t.integer "project_id", :null => false t.integer "project_id", :null => false
t.integer "user_id", :null => false t.integer "user_id", :null => false