整理迁移文件,修改迁移文件运行错误

This commit is contained in:
sw 2014-07-31 13:40:02 +08:00
parent a9fad79c8d
commit 5564ca063b
11 changed files with 65 additions and 152 deletions

View File

@ -2,7 +2,7 @@ class CreateOpenSourceProjects < ActiveRecord::Migration
def change def change
create_table :open_source_projects do |t| create_table :open_source_projects do |t|
t.column "name", :string, :default => nil, :null => true t.column "name", :string, :default => nil, :null => true
t.column "description", :string, :default => '', :null => true t.column "description", :text, :null => true
t.column "commit_count", :integer, :default => 0 t.column "commit_count", :integer, :default => 0
t.column "code_line", :integer, :default => 0 t.column "code_line", :integer, :default => 0
t.column "users_count",:integer, :default => 0 t.column "users_count",:integer, :default => 0

View File

@ -1,9 +0,0 @@
class ChangeDescriptionTypeToOpenSourceProject < ActiveRecord::Migration
def up
change_column :open_source_projects, :description, :text
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,5 +0,0 @@
class DropUserScores < ActiveRecord::Migration
def change
drop_table :user_scores
end
end

View File

@ -1,11 +0,0 @@
class CreateUserScores < ActiveRecord::Migration
def change
create_table :user_scores do |t|
t.integer :user_id
t.integer :collaboration
t.integer :influence
t.integer :skill
t.integer :activity
end
end
end

View File

@ -4,49 +4,49 @@ class AddCourseRoles < ActiveRecord::Migration
# 添加课程权限 # 添加课程权限
Role.all.each do |role| Role.all.each do |role|
if role.name == 'Non member' if role.name == 'Non member'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
role.permissions.append(:add_course ) role.add_permission!(:add_course )
elsif role.name == 'Anonymous' elsif role.name == 'Anonymous'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
elsif role.name == 'Manager' elsif role.name == 'Manager'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
role.permissions.append(:add_course ) role.add_permission!(:add_course )
role.permissions.append(:close_course ) role.add_permission!(:close_course )
role.permissions.append(:select_course_modules ) role.add_permission!(:select_course_modules )
role.permissions.append(:edit_course ) role.add_permission!(:edit_course )
elsif role.name =='Developer' elsif role.name =='Developer'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
role.permissions.append(:add_course ) role.add_permission!(:add_course )
role.permissions.append(:close_course ) role.add_permission!(:close_course )
role.permissions.append(:select_course_modules ) role.add_permission!(:select_course_modules )
role.permissions.append(:edit_course ) role.add_permission!(:edit_course )
elsif role.name == 'Reporter' elsif role.name == 'Reporter'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
elsif role.name == '助教' elsif role.name == '助教'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
role.permissions.append(:add_course ) role.add_permission!(:add_course )
role.permissions.append(:select_course_modules ) role.add_permission!(:select_course_modules )
role.permissions.append(:edit_course ) role.add_permission!(:edit_course )
elsif role.name == '老师' elsif role.name == '老师'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
role.permissions.append(:add_course ) role.add_permission!(:add_course )
role.permissions.append(:close_course ) role.add_permission!(:close_course )
role.permissions.append(:select_course_modules ) role.add_permission!(:select_course_modules )
role.permissions.append(:edit_course ) role.add_permission!(:edit_course )
elsif role.name == '学生' elsif role.name == '学生'
role.permissions.append(:view_course ) role.add_permission!(:view_course )
role.permissions.append(:search_course ) role.add_permission!(:search_course )
end end
role.permissions.append(:view_course_files ) role.add_permission!(:view_course_files )
role.permissions.append(:view_course_journals_for_messages ) role.add_permission!(:view_course_journals_for_messages )
role.permissions.append(:view_course_messages ) role.add_permission!(:view_course_messages )
role.save(:validate => false) role.save(:validate => false)
end end
end end

View File

@ -9,12 +9,13 @@ class CreateFirstPages < ActiveRecord::Migration
t.timestamps t.timestamps
end end
fp = FirstPage.new fp = FirstPage.new
fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.web_title = "Trustie - 为大学生技术创新筑巢"
fp.title = "Trustie在线项目托管平台" fp.title = "Trustie在线项目托管平台"
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project" fp.page_type = "project"
fp.save fp.save(:validate => false)
end end
end end

View File

@ -6,12 +6,12 @@ class AddContestAndCourseFirstPage < ActiveRecord::Migration
fp.title = "Trustie在线课程实践平台" fp.title = "Trustie在线课程实践平台"
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course" fp.page_type = "course"
fp.save fp.save(:validate => false)
fp1 = FirstPage.new fp1 = FirstPage.new
fp1.web_title = "" fp1.web_title = ""
fp1.title = "Trustie在线竞赛实战平台" fp1.title = "Trustie在线竞赛实战平台"
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest" fp1.page_type = "contest"
fp1.save fp1.save(:validate => false)
end end
end end

View File

@ -3,7 +3,7 @@ class SetWebTitle < ActiveRecord::Migration
def change def change
FirstPage.all.each do |fp| FirstPage.all.each do |fp|
fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.web_title = "Trustie - 为大学生技术创新筑巢"
fp.save fp.save(:validate => false)
end end
end end
end end

View File

@ -2,7 +2,7 @@ class SetSortType < ActiveRecord::Migration
def change def change
FirstPage.all.each do |fp| FirstPage.all.each do |fp|
fp.sort_type = 1 fp.sort_type = 1
fp.save fp.save(:validate => false)
end end
end end
end end

View File

@ -9,7 +9,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project" fp.page_type = "project"
fp.sort_type = 1 fp.sort_type = 1
fp.save fp.save(:validate => false)
else else
fp = pro_fps.first fp = pro_fps.first
fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.web_title = "Trustie - 为大学生技术创新筑巢"
@ -17,7 +17,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
fp.page_type = "project" fp.page_type = "project"
fp.sort_type = 1 fp.sort_type = 1
fp.save fp.save(:validate => false)
end end
course_fps = FirstPage.where("page_type = 'course'") course_fps = FirstPage.where("page_type = 'course'")
if course_fps.nil? || course_fps.first.nil? if course_fps.nil? || course_fps.first.nil?
@ -27,7 +27,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course" fp.page_type = "course"
fp.sort_type = 1 fp.sort_type = 1
fp.save fp.save(:validate => false)
else else
fp = course_fps.first fp = course_fps.first
fp.web_title = "Trustie - 为大学生技术创新筑巢" fp.web_title = "Trustie - 为大学生技术创新筑巢"
@ -35,7 +35,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course" fp.page_type = "course"
fp.sort_type = 1 fp.sort_type = 1
fp.save fp.save(:validate => false)
end end
contest_fps = FirstPage.where("page_type = 'contest'") contest_fps = FirstPage.where("page_type = 'contest'")
if contest_fps.nil? || contest_fps.first.nil? if contest_fps.nil? || contest_fps.first.nil?
@ -45,7 +45,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest" fp1.page_type = "contest"
fp1.sort_type = 1 fp1.sort_type = 1
fp1.save fp1.save(:validate => false)
else else
fp1 = contest_fps.first fp1 = contest_fps.first
fp1.web_title = "Trustie - 为大学生技术创新筑巢" fp1.web_title = "Trustie - 为大学生技术创新筑巢"
@ -53,7 +53,7 @@ class RepairFirstPage < ActiveRecord::Migration
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest" fp1.page_type = "contest"
fp1.sort_type = 1 fp1.sort_type = 1
fp1.save fp1.save(:validate => false)
end end
end end
end end

View File

@ -177,58 +177,6 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
create_table "code_review_assignments", :force => true do |t|
t.integer "issue_id"
t.integer "change_id"
t.integer "attachment_id"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.string "action_type"
t.integer "changeset_id"
end
create_table "code_review_project_settings", :force => true do |t|
t.integer "project_id"
t.integer "tracker_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "updated_by"
t.boolean "hide_code_review_tab", :default => false
t.integer "auto_relation", :default => 1
t.integer "assignment_tracker_id"
t.text "auto_assign"
t.integer "lock_version", :default => 0, :null => false
t.boolean "tracker_in_review_dialog", :default => false
end
create_table "code_review_user_settings", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "mail_notification", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "code_reviews", :force => true do |t|
t.integer "project_id"
t.integer "change_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "line"
t.integer "updated_by_id"
t.integer "lock_version", :default => 0, :null => false
t.integer "status_changed_from"
t.integer "status_changed_to"
t.integer "issue_id"
t.string "action_type"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.integer "attachment_id"
t.integer "file_count", :default => 0, :null => false
t.boolean "diff_all"
end
create_table "comments", :force => true do |t| create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false t.integer "commented_id", :default => 0, :null => false
@ -419,9 +367,9 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
t.string "web_title" t.string "web_title"
t.string "title" t.string "title"
t.text "description" t.text "description"
t.string "page_type"
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.string "page_type"
t.integer "sort_type" t.integer "sort_type"
t.integer "image_width", :default => 107 t.integer "image_width", :default => 107
t.integer "image_height", :default => 63 t.integer "image_height", :default => 63
@ -847,18 +795,18 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
create_table "relative_memos", :force => true do |t| create_table "relative_memos", :force => true do |t|
t.integer "osp_id" 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", :limit => 16777215, :null => false t.text "content", :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"
@ -882,19 +830,6 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
create_table "rich_rich_files", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "rich_file_file_name"
t.string "rich_file_content_type"
t.integer "rich_file_file_size"
t.datetime "rich_file_updated_at"
t.string "owner_type"
t.integer "owner_id"
t.text "uri_cache"
t.string "simplified_type", :default => "file"
end
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1 t.integer "position", :default => 1
@ -945,11 +880,10 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
t.string "url" t.string "url"
t.string "title" t.string "title"
t.integer "share_type" t.integer "share_type"
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 "project_id" t.integer "project_id"
t.integer "user_id" t.integer "user_id"
t.string "description"
end end
create_table "softapplications", :force => true do |t| create_table "softapplications", :force => true do |t|
@ -1055,8 +989,8 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
t.integer "zip_code" t.integer "zip_code"
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.string "technical_title"
t.integer "identity" t.integer "identity"
t.string "technical_title"
t.string "student_id" t.string "student_id"
t.string "teacher_realname" t.string "teacher_realname"
t.string "student_realname" t.string "student_realname"
@ -1114,6 +1048,9 @@ ActiveRecord::Schema.define(:version => 20140730024419) do
t.integer "active" t.integer "active"
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 "level"
t.integer "file"
t.integer "issue"
end end
create_table "user_statuses", :force => true do |t| create_table "user_statuses", :force => true do |t|