diff --git a/db/migrate/20180920063955_create_graduation_topics.rb b/db/migrate/20180920063955_create_graduation_topics.rb
deleted file mode 100644
index 5e7a4640e..000000000
--- a/db/migrate/20180920063955_create_graduation_topics.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-class CreateGraduationTopics < ActiveRecord::Migration[5.2]
- def change
- create_table :graduation_topics do |t|
- t.references :user
- t.references :course
- t.integer :tea_id
- t.string :name
- t.text :description
- t.integer :status, :default => 0
- t.integer :topic_type
- t.integer :source
- t.integer :property
- t.integer :property_two
- t.string :source_unit
- t.integer :repeat
- t.string :province
- t.string :city
- t.boolean :is_public, :default => 0
-
- t.timestamps
- end
- add_index :graduation_topics, :user_id
- add_index :graduation_topics, :course_id
- add_index :graduation_topics, :tea_id
- end
-end
diff --git a/db/migrate/20181024015607_add_column_to_poll.rb b/db/migrate/20181024015607_add_column_to_poll.rb
deleted file mode 100644
index 65ebe98d3..000000000
--- a/db/migrate/20181024015607_add_column_to_poll.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddColumnToPoll < ActiveRecord::Migration[5.2]
- # 问卷是否实名
- def change
- add_column :polls, :un_anonymous, :boolean, :default => 0
- end
-end
diff --git a/db/migrate/20181105031300_add_repo_name_to_shixuns.rb b/db/migrate/20181105031300_add_repo_name_to_shixuns.rb
deleted file mode 100644
index 3210184ad..000000000
--- a/db/migrate/20181105031300_add_repo_name_to_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddRepoNameToShixuns < ActiveRecord::Migration[5.2]
- def change
- add_column :shixuns, :repo_name, :string
- end
-end
diff --git a/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb b/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb
deleted file mode 100644
index 70ca92abb..000000000
--- a/db/migrate/20181105061745_add_repo_name_to_myshixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddRepoNameToMyshixuns < ActiveRecord::Migration[5.2]
- def change
- add_column :myshixuns, :repo_name, :string
- end
-end
diff --git a/db/migrate/20181115071148_create_relationships.rb b/db/migrate/20181115071148_create_relationships.rb
deleted file mode 100644
index 4437e9ea5..000000000
--- a/db/migrate/20181115071148_create_relationships.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class CreateRelationships < ActiveRecord::Migration[5.2]
- def change
- create_table :relationships do |t|
- t.integer :follower_id
- t.integer :followed_id
-
- t.timestamps
- end
- add_index :relationships, :followed_id
- add_index :relationships, :follower_id
- add_index :relationships, [:follower_id, :followed_id], unique: true
- end
-end
diff --git a/db/migrate/20181118075620_sync_gitlab_admin.rb b/db/migrate/20181118075620_sync_gitlab_admin.rb
deleted file mode 100644
index 17cb3bd18..000000000
--- a/db/migrate/20181118075620_sync_gitlab_admin.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class SyncGitlabAdmin < ActiveRecord::Migration[5.2]
- def change
- user = User.find_by_login("forge01")
- user.update_column(:mail, 'admin@example.com')
- end
-end
diff --git a/db/migrate/20181207064509_add_cloud_url_to_attachments.rb b/db/migrate/20181207064509_add_cloud_url_to_attachments.rb
deleted file mode 100644
index 6dd3ffb6d..000000000
--- a/db/migrate/20181207064509_add_cloud_url_to_attachments.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddCloudUrlToAttachments < ActiveRecord::Migration[5.2]
- def change
- add_column :attachments, :cloud_url, :string, default: ''
- end
-end
diff --git a/db/migrate/20181213024859_add_averge_star_to_shixuns.rb b/db/migrate/20181213024859_add_averge_star_to_shixuns.rb
deleted file mode 100644
index c801c8675..000000000
--- a/db/migrate/20181213024859_add_averge_star_to_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddAvergeStarToShixuns < ActiveRecord::Migration[5.2]
- def change
- add_column :shixuns, :averge_star, :float, :default => 0
- end
-end
diff --git a/db/migrate/20181213025239_sync_averger_star_to_shixun.rb b/db/migrate/20181213025239_sync_averger_star_to_shixun.rb
deleted file mode 100644
index e117475a4..000000000
--- a/db/migrate/20181213025239_sync_averger_star_to_shixun.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class SyncAvergerStarToShixun < ActiveRecord::Migration[5.2]
- def change
- Shixun.find_each do |shixun|
- averge_star = Game.find_by_sql("select ifnull(sum(g.star),0)/ifnull(count(*),1) as averge_star from (games g left join
- (myshixuns m join shixuns s on s.id = m.shixun_id) on m.id = g.myshixun_id)
- where star != 0 and s.id = #{shixun.id}").first.try(:averge_star)
- averge_star = averge_star || 5
- puts(averge_star)
- shixun.update_column(:averge_star, averge_star.round(1))
- end
- end
-end
diff --git a/db/migrate/20181228095820_create_shixun_infos.rb b/db/migrate/20181228095820_create_shixun_infos.rb
deleted file mode 100644
index f5c72d5a3..000000000
--- a/db/migrate/20181228095820_create_shixun_infos.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class CreateShixunInfos < ActiveRecord::Migration[5.2]
- def change
- create_table :shixun_infos do |t|
- t.longtext :propaedeutics
- t.longtext :description
- t.longtext :evaluate_script
- t.integer :shixun_id
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20181228115324_add_index_to_users.rb b/db/migrate/20181228115324_add_index_to_users.rb
deleted file mode 100644
index ccd8f771f..000000000
--- a/db/migrate/20181228115324_add_index_to_users.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIndexToUsers < ActiveRecord::Migration[5.2]
- def change
- add_index :users, :experience
- end
-end
diff --git a/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb b/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb
deleted file mode 100644
index 08a5d0e3a..000000000
--- a/db/migrate/20190108074759_modify_status_and_visits_for_subjects.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ModifyStatusAndVisitsForSubjects < ActiveRecord::Migration[5.2]
- def change
- change_column :subjects, :status, :integer, :default => 0
- change_column :subjects, :visits, :integer, :default => 1
- end
-end
diff --git a/db/migrate/20190109005614_add_opening_time_for_shixuns.rb b/db/migrate/20190109005614_add_opening_time_for_shixuns.rb
deleted file mode 100644
index d02cd6113..000000000
--- a/db/migrate/20190109005614_add_opening_time_for_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddOpeningTimeForShixuns < ActiveRecord::Migration[5.2]
- def change
- add_column :shixuns, :opening_time, :string
- end
-end
diff --git a/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb b/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb
deleted file mode 100644
index b3360c424..000000000
--- a/db/migrate/20190109013210_modify_opening_time_for_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ModifyOpeningTimeForShixuns < ActiveRecord::Migration[5.2]
- def change
- change_column :shixuns, :opening_time, :datetime
- end
-end
diff --git a/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb b/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb
deleted file mode 100644
index fb0b4d3aa..000000000
--- a/db/migrate/20190111063956_add_averge_star_default_for_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddAvergeStarDefaultForShixuns < ActiveRecord::Migration[5.2]
- def change
- change_column :shixuns, :averge_star, :float, :default => 5
- end
-end
diff --git a/db/migrate/20190120063702_sync_reponame.rb b/db/migrate/20190120063702_sync_reponame.rb
deleted file mode 100644
index c40eba131..000000000
--- a/db/migrate/20190120063702_sync_reponame.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class SyncReponame < ActiveRecord::Migration[5.2]
- def change
- g = Gitlab.client
- myshixuns = Myshixun.where("repo_name is null")
- myshixuns.find_each do |myshixun|
- begin
- puts myshixun.id
- repo_name = g.project(myshixun.gpid).path_with_namespace
- puts repo_name
- myshixun.update_column(:repo_name, repo_name)
- rescue Exception => e
- Rails.logger.error("e.message")
- end
- end
- end
-end
diff --git a/db/migrate/20190220014052_add_shixuns_count_to_stage.rb b/db/migrate/20190220014052_add_shixuns_count_to_stage.rb
deleted file mode 100644
index caf459a8e..000000000
--- a/db/migrate/20190220014052_add_shixuns_count_to_stage.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddShixunsCountToStage < ActiveRecord::Migration[5.2]
- def change
- add_column :stages, :shixuns_count, :integer, default: 0
- end
-end
diff --git a/db/migrate/20190220061013_add_shixuns_count_to_subject.rb b/db/migrate/20190220061013_add_shixuns_count_to_subject.rb
deleted file mode 100644
index 3f803d2f1..000000000
--- a/db/migrate/20190220061013_add_shixuns_count_to_subject.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddShixunsCountToSubject < ActiveRecord::Migration[5.2]
- def change
- add_column :subjects, :shixuns_count, :integer, default: 0
- end
-end
diff --git a/db/migrate/20190220074947_sync_cache_count_for_subjects.rb b/db/migrate/20190220074947_sync_cache_count_for_subjects.rb
deleted file mode 100644
index ce2b22d62..000000000
--- a/db/migrate/20190220074947_sync_cache_count_for_subjects.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class SyncCacheCountForSubjects < ActiveRecord::Migration[5.2]
- def change
- Subject.find_each do |s|
- Subject.reset_counters s.id, :shixuns
- Subject.reset_counters s.id, :stages
- end
- end
-end
diff --git a/db/migrate/20190221003048_add_users_count_to_shixun.rb b/db/migrate/20190221003048_add_users_count_to_shixun.rb
deleted file mode 100644
index dffca5be9..000000000
--- a/db/migrate/20190221003048_add_users_count_to_shixun.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddUsersCountToShixun < ActiveRecord::Migration[5.2]
- def change
- add_column :shixuns, :users_count, :integer, default: 0
- end
-end
diff --git a/db/migrate/20190221003137_sync_users_count_for_shixun.rb b/db/migrate/20190221003137_sync_users_count_for_shixun.rb
deleted file mode 100644
index 155ddda58..000000000
--- a/db/migrate/20190221003137_sync_users_count_for_shixun.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class SyncUsersCountForShixun < ActiveRecord::Migration[5.2]
- def change
- Shixun.find_each do |s|
- Shixun.reset_counters s.id, :users_count
- end
- end
-end
diff --git a/db/migrate/20190228030508_delete_none_myshixun_games.rb b/db/migrate/20190228030508_delete_none_myshixun_games.rb
deleted file mode 100644
index 89130d3fa..000000000
--- a/db/migrate/20190228030508_delete_none_myshixun_games.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class DeleteNoneMyshixunGames < ActiveRecord::Migration[5.2]
- def change
- games = Game.where.not(myshixun_id: Myshixun.where(nil).pluck(:id))
- games.destroy_all
- end
-end
diff --git a/db/migrate/20190304082236_create_challenge_answers.rb b/db/migrate/20190304082236_create_challenge_answers.rb
deleted file mode 100644
index 630c92661..000000000
--- a/db/migrate/20190304082236_create_challenge_answers.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class CreateChallengeAnswers < ActiveRecord::Migration[5.2]
- def change
- create_table :challenge_answers do |t|
- t.string :name
- t.longtext :contents
- t.integer :score
- t.integer :level
- t.references :challenge, index: true
- t.timestamps
- end
-
- end
-end
diff --git a/db/migrate/20190304082811_create_course_members.rb b/db/migrate/20190304082811_create_course_members.rb
deleted file mode 100644
index fd54891fd..000000000
--- a/db/migrate/20190304082811_create_course_members.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class CreateCourseMembers < ActiveRecord::Migration[5.2]
- def change
- create_table :course_members do |t|
- t.integer :course_id
- t.integer :user_id
- t.integer :course_group_id, default: 0
- t.integer :graduation_group_id, default: 0
- t.integer :role, default: 0
- t.boolean :is_active, default: 1
-
- t.timestamps
- end
-
- add_index :course_members, :course_id
- add_index :course_members, :user_id
- add_index :course_members, :course_group_id
- add_index :course_members, :graduation_group_id
- end
-end
diff --git a/db/migrate/20190305015556_modify_answer_open_for_games.rb b/db/migrate/20190305015556_modify_answer_open_for_games.rb
deleted file mode 100644
index 7ae83ac9e..000000000
--- a/db/migrate/20190305015556_modify_answer_open_for_games.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ModifyAnswerOpenForGames < ActiveRecord::Migration[5.2]
- def change
- change_column :games, :answer_open, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb b/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb
deleted file mode 100644
index 9c026fc3f..000000000
--- a/db/migrate/20190305074102_add_checkout_answer_score_for_games.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddCheckoutAnswerScoreForGames < ActiveRecord::Migration[5.2]
- def change
- add_column :games, :answer_deduction, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190305080703_add_course_members_count_to_course.rb b/db/migrate/20190305080703_add_course_members_count_to_course.rb
deleted file mode 100644
index d38aaca5b..000000000
--- a/db/migrate/20190305080703_add_course_members_count_to_course.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddCourseMembersCountToCourse < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :course_members_count, :integer, default: 0
-
- Course.find_each do |c|
- Course.reset_counters c.id, :course_members
- end
- end
-end
diff --git a/db/migrate/20190306023331_add_score_for_test_sets.rb b/db/migrate/20190306023331_add_score_for_test_sets.rb
deleted file mode 100644
index 08b67ad85..000000000
--- a/db/migrate/20190306023331_add_score_for_test_sets.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddScoreForTestSets < ActiveRecord::Migration[5.2]
- def change
- add_column :test_sets, :score, :integer
- add_column :challenges, :test_set_score, :boolean, :default => false
- end
-end
diff --git a/db/migrate/20190306064421_add_answer_for_challenge_answer.rb b/db/migrate/20190306064421_add_answer_for_challenge_answer.rb
deleted file mode 100644
index 32a6a6aa2..000000000
--- a/db/migrate/20190306064421_add_answer_for_challenge_answer.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class AddAnswerForChallengeAnswer < ActiveRecord::Migration[5.2]
- def change
- challenges = Challenge.where("answer is not null")
- challenges.find_each do |c|
- puts "####################{c.id}"
- ChallengeAnswer.create(name: "解题代码", contents: "#{c.answer}", level: 1, score: 100, challenge_id: c.id)
- end
-
- end
-end
diff --git a/db/migrate/20190307063217_add_pod_life_to_shixuns.rb b/db/migrate/20190307063217_add_pod_life_to_shixuns.rb
deleted file mode 100644
index e596367f2..000000000
--- a/db/migrate/20190307063217_add_pod_life_to_shixuns.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddPodLifeToShixuns < ActiveRecord::Migration[5.2]
- def change
- add_column :shixuns, :pod_life, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190309085449_migrate_course_members.rb b/db/migrate/20190309085449_migrate_course_members.rb
deleted file mode 100644
index a6d049dd7..000000000
--- a/db/migrate/20190309085449_migrate_course_members.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-class MigrateCourseMembers < ActiveRecord::Migration[5.2]
- def change
- # add_column :course_groups, :position, :integer, default: 0
-
- Course.find_each do |course|
- position = 1
- course.course_groups.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each do |group|
- group.update_attribute(:position, position)
- position += 1
- end
- end
-
-
- add_column :course_groups, :course_members_count, :integer, default: 0
-
- CourseGroup.find_each do |g|
- CourseGroup.reset_counters g.id, :course_members
- end
-
- ActiveRecord::Base.transaction do
- begin
- Member.where("course_id != -1").includes(:member_roles).find_each(batch_size: 500) do |member|
- puts(member.id)
- member.member_roles.each do |role|
- course_member_role = role.role_id == 3 ? 1 : (role.role_id == 9 ? 2 : (role.role_id == 7 ? 3 : 4))
- member_group_id = role.role_id == 10 ? member.course_group_id : 0
- CourseMember.create!(course_id: member.course_id, user_id: member.user_id, course_group_id: member_group_id,
- graduation_group_id: member.graduation_group_id, role: course_member_role, is_active: role.is_current)
- end
- end
- rescue Exception => e
- uid_logger_error(e.message)
- tip_exception("migrate_course_members 迁移失败!")
- raise ActiveRecord::Rollback
- end
- end
- end
-end
diff --git a/db/migrate/20190309091056_add_course_member_id.rb b/db/migrate/20190309091056_add_course_member_id.rb
deleted file mode 100644
index 86993d725..000000000
--- a/db/migrate/20190309091056_add_course_member_id.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class AddCourseMemberId < ActiveRecord::Migration[5.2]
- def change
- add_column :student_graduation_topics, :course_member_id, :integer
- add_index :student_graduation_topics, :course_member_id
-
- StudentGraduationTopic.find_each do |student|
- course_member = CourseMember.where(course_id: student.course_id, user_id: student.user_id,
- role: 4).first
- student.update_column("course_member_id", course_member.try(:id)) if course_member.present?
- end
-
- add_column :teacher_course_groups, :course_member_id, :integer
- add_index :teacher_course_groups, :course_member_id
-
- TeacherCourseGroup.find_each do |teacher|
- course_member = CourseMember.where(course_id: teacher.course_id, user_id: teacher.user_id,
- role: [1, 2, 3]).first
- teacher.update_column("course_member_id", course_member.try(:id)) if course_member.present?
- end
- end
-end
diff --git a/db/migrate/20190311064138_add_course_groups_count_to_course.rb b/db/migrate/20190311064138_add_course_groups_count_to_course.rb
deleted file mode 100644
index ecd11e7cb..000000000
--- a/db/migrate/20190311064138_add_course_groups_count_to_course.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddCourseGroupsCountToCourse < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :course_groups_count, :integer, default: 0
-
- Course.find_each do |c|
- Course.reset_counters c.id, :course_groups
- end
- end
-end
diff --git a/db/migrate/20190311080729_add_position_to_course_groups.rb b/db/migrate/20190311080729_add_position_to_course_groups.rb
deleted file mode 100644
index 4a59a7d97..000000000
--- a/db/migrate/20190311080729_add_position_to_course_groups.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddPositionToCourseGroups < ActiveRecord::Migration[5.2]
- def change
-
- end
-end
diff --git a/db/migrate/20190311090818_create_course_second_categories.rb b/db/migrate/20190311090818_create_course_second_categories.rb
deleted file mode 100644
index 51850c2fd..000000000
--- a/db/migrate/20190311090818_create_course_second_categories.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class CreateCourseSecondCategories < ActiveRecord::Migration[5.2]
- def change
- create_table :course_second_categories do |t|
- t.references :course
- t.string :category_type
- t.string :name
- t.integer :position
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20190312024018_migrate_course_second_category.rb b/db/migrate/20190312024018_migrate_course_second_category.rb
deleted file mode 100644
index 382c6fd6f..000000000
--- a/db/migrate/20190312024018_migrate_course_second_category.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class MigrateCourseSecondCategory < ActiveRecord::Migration[5.2]
- def change
- add_column :homework_commons, :course_second_category_id, :integer, default: 0
- add_index :homework_commons, :course_second_category_id
- add_column :course_second_categories, :course_module_id, :integer
- add_index :course_second_categories, :course_module_id
-
- Course.find_each do |course|
- homework_position = 1
- course_module = course.course_modules.where(module_type: "shixun_homework").first
- course.course_homework_categories.reorder("CONVERT(name USING gbk) COLLATE gbk_chinese_ci ASC").find_each do |category|
- new_category = CourseSecondCategory.create!(course_id: course.id, name: category.name, category_type: "shixun_homework",
- position: homework_position, course_module_id: course_module.id)
- course.homework_commons.where(course_homework_category_id: category.id).update_all(course_second_category_id: new_category.id)
- homework_position += 1
- end
- end
- end
-end
diff --git a/db/migrate/20190312032623_add_course_second_category_to_attachment.rb b/db/migrate/20190312032623_add_course_second_category_to_attachment.rb
deleted file mode 100644
index 972422e43..000000000
--- a/db/migrate/20190312032623_add_course_second_category_to_attachment.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddCourseSecondCategoryToAttachment < ActiveRecord::Migration[5.2]
- def change
- add_column :attachments, :course_second_category_id, :integer, default: 0
- add_index :attachments, :course_second_category_id
- end
-end
diff --git a/db/migrate/20190321081720_add_praises_count_to_messages.rb b/db/migrate/20190321081720_add_praises_count_to_messages.rb
deleted file mode 100644
index 14f9260cb..000000000
--- a/db/migrate/20190321081720_add_praises_count_to_messages.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class AddPraisesCountToMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :messages, :praises_count, :integer, :default => 0
-
- Message.find_each do |msg|
- total_count = msg.praise_treads.liker.count
- puts "====> set message's praises_count to #{total_count}"
- msg.update_column(:praises_count, total_count)
- end
- end
-end
diff --git a/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb b/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb
deleted file mode 100644
index 15dd3f6e9..000000000
--- a/db/migrate/20190321091429_change_praise_or_tread_default_in_praise_treads.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ChangePraiseOrTreadDefaultInPraiseTreads < ActiveRecord::Migration[5.2]
- def change
- change_column_default :praise_treads, :praise_or_tread, from: nil, to: 1
- end
-end
diff --git a/db/migrate/20190322065716_create_message_details.rb b/db/migrate/20190322065716_create_message_details.rb
deleted file mode 100644
index 5fd1ba7d8..000000000
--- a/db/migrate/20190322065716_create_message_details.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class CreateMessageDetails < ActiveRecord::Migration[5.2]
- def change
- create_table :message_details do |t|
- t.longtext :content
- t.integer :message_id
-
- t.timestamps
- end
- add_index :message_details, :message_id
- end
-end
diff --git a/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb b/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb
deleted file mode 100644
index be747c898..000000000
--- a/db/migrate/20190322070515_move_content_of_messages_to_message_details.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class MoveContentOfMessagesToMessageDetails < ActiveRecord::Migration[5.2]
- def change
- Message.find_each do |msg|
- unless msg.message_detail.present?
- message_detail = MessageDetail.create(message: msg, content: msg.content)
- puts "-------> create MessageDetail success: id is #{message_detail.id}"
- end
- end
- end
-end
diff --git a/db/migrate/20190322091313_remove_content_from_messages.rb b/db/migrate/20190322091313_remove_content_from_messages.rb
deleted file mode 100644
index ee6830e53..000000000
--- a/db/migrate/20190322091313_remove_content_from_messages.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class RemoveContentFromMessages < ActiveRecord::Migration[5.2]
- def change
- remove_column :messages, :content, :longtext
- end
-end
diff --git a/db/migrate/20190323005303_modify_graduation_topics.rb b/db/migrate/20190323005303_modify_graduation_topics.rb
deleted file mode 100644
index 18998fdcd..000000000
--- a/db/migrate/20190323005303_modify_graduation_topics.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class ModifyGraduationTopics < ActiveRecord::Migration[5.2]
- def change
- rename_column :graduation_topics, :source, :topic_source
- rename_column :graduation_topics, :property, :topic_property_first
- rename_column :graduation_topics, :property_two, :topic_property_second
- rename_column :graduation_topics, :repeat, :topic_repeat
- end
-end
diff --git a/db/migrate/20190325022227_add_is_public_to_graduation_task.rb b/db/migrate/20190325022227_add_is_public_to_graduation_task.rb
deleted file mode 100644
index 159aa90e9..000000000
--- a/db/migrate/20190325022227_add_is_public_to_graduation_task.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class AddIsPublicToGraduationTask < ActiveRecord::Migration[5.2]
- def change
- add_column :graduation_tasks, :is_public, :boolean, default: false
- add_column :graduation_tasks, :late_time, :datetime
-
- GraduationTask.where(status: 3).update_all(status: 4)
- end
-end
diff --git a/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb b/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb
deleted file mode 100644
index 3b59e56e8..000000000
--- a/db/migrate/20190325023830_change_digest_to_string_in_attachments.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ChangeDigestToStringInAttachments < ActiveRecord::Migration[5.2]
- def change
- change_column :attachments, :digest, :string, :limit => 60
- end
-end
diff --git a/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb b/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb
deleted file mode 100644
index 2ff25360d..000000000
--- a/db/migrate/20190326015900_add_hidden_for_journal_for_messages.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddHiddenForJournalForMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :journals_for_messages, :hidden, :boolean, :default => false
- end
-end
diff --git a/db/migrate/20190326095920_add_is_hidden_to_messages.rb b/db/migrate/20190326095920_add_is_hidden_to_messages.rb
deleted file mode 100644
index ee97a3f6c..000000000
--- a/db/migrate/20190326095920_add_is_hidden_to_messages.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddIsHiddenToMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :messages, :is_hidden, :boolean, :default => false
- add_index :messages, :is_hidden
- end
-end
diff --git a/db/migrate/20190327063241_course_group_count_cache.rb b/db/migrate/20190327063241_course_group_count_cache.rb
deleted file mode 100644
index cf0b868ff..000000000
--- a/db/migrate/20190327063241_course_group_count_cache.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class CourseGroupCountCache < ActiveRecord::Migration[5.2]
- def change
-
- end
-end
diff --git a/db/migrate/20190329091942_add_index_to_shixun_infos.rb b/db/migrate/20190329091942_add_index_to_shixun_infos.rb
deleted file mode 100644
index c7a14dfaa..000000000
--- a/db/migrate/20190329091942_add_index_to_shixun_infos.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIndexToShixunInfos < ActiveRecord::Migration[5.2]
- def change
- add_index :shixun_infos, :shixun_id, unique: true
- end
-end
diff --git a/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb b/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb
deleted file mode 100644
index 4e25ab522..000000000
--- a/db/migrate/20190401083919_change_quotes_to_integer_in_attachments.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ChangeQuotesToIntegerInAttachments < ActiveRecord::Migration[5.2]
- def change
- change_column :attachments, :quotes, :integer, :default => 0
- add_index :attachments, :quotes
- end
-end
diff --git a/db/migrate/20190401094623_add_index_to_attachments_is_public.rb b/db/migrate/20190401094623_add_index_to_attachments_is_public.rb
deleted file mode 100644
index d098253d0..000000000
--- a/db/migrate/20190401094623_add_index_to_attachments_is_public.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIndexToAttachmentsIsPublic < ActiveRecord::Migration[5.2]
- def change
- add_index :attachments, :is_public
- end
-end
diff --git a/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb b/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb
deleted file mode 100644
index 5a7ea9c16..000000000
--- a/db/migrate/20190402015918_add_invalid_to_graduation_work_score.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddInvalidToGraduationWorkScore < ActiveRecord::Migration[5.2]
- def change
- add_column :graduation_work_scores, :is_invalid, :boolean, default: false
- end
-end
diff --git a/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
deleted file mode 100644
index b4bc9a2f6..000000000
--- a/db/migrate/20190402083252_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 1)
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
-else
- class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
-end
-ActsAsTaggableOnMigration.class_eval do
- def self.up
- unless ActiveRecord::Base.connection.table_exists? 'tags'
- create_table :tags do |t|
- t.string :name
- end
- end
-
- unless ActiveRecord::Base.connection.table_exists? 'taggings'
- create_table :taggings do |t|
- t.references :tag
-
- # You should make sure that the column created is
- # long enough to store the required class names.
- t.references :taggable, polymorphic: true
- t.references :tagger, polymorphic: true
-
- # Limit is created to prevent MySQL error on index
- # length for MyISAM table type: http://bit.ly/vgW2Ql
- t.string :context, limit: 128
-
- t.datetime :created_at
- end
- end
-
- # add_index :taggings, :tag_id
- # add_index :taggings, [:taggable_id, :taggable_type, :context]
- end
-
- def self.down
- drop_table :taggings
- drop_table :tags
- end
-end
diff --git a/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb
deleted file mode 100644
index 7206c90e6..000000000
--- a/db/migrate/20190402083253_add_missing_unique_indices.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 2)
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
-else
- class AddMissingUniqueIndices < ActiveRecord::Migration; end
-end
-AddMissingUniqueIndices.class_eval do
- def self.up
- # add_index :tags, :name, unique: true
-
- remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
- remove_index :taggings, [:taggable_id, :taggable_type, :context]
- add_index :taggings,
- [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
- unique: true, name: 'taggings_idx'
- end
-
- def self.down
- remove_index :tags, :name
-
- remove_index :taggings, name: 'taggings_idx'
-
- add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
- add_index :taggings, [:taggable_id, :taggable_type, :context]
- end
-end
diff --git a/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
deleted file mode 100644
index 5409eef63..000000000
--- a/db/migrate/20190402083254_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 3)
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
-else
- class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
-end
-AddTaggingsCounterCacheToTags.class_eval do
- def self.up
- add_column :tags, :taggings_count, :integer, default: 0
-
- ActsAsTaggableOn::Tag.reset_column_information
- ActsAsTaggableOn::Tag.find_each do |tag|
- ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
- end
- end
-
- def self.down
- remove_column :tags, :taggings_count
- end
-end
diff --git a/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb
deleted file mode 100644
index 097600b59..000000000
--- a/db/migrate/20190402083255_add_missing_taggable_index.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 4)
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
-else
- class AddMissingTaggableIndex < ActiveRecord::Migration; end
-end
-AddMissingTaggableIndex.class_eval do
- def self.up
- add_index :taggings, [:taggable_id, :taggable_type, :context]
- end
-
- def self.down
- remove_index :taggings, [:taggable_id, :taggable_type, :context]
- end
-end
diff --git a/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
deleted file mode 100644
index 731f66c5a..000000000
--- a/db/migrate/20190402083256_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 5)
-# This migration is added to circumvent issue #623 and have special characters
-# work properly
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
-else
- class ChangeCollationForTagNames < ActiveRecord::Migration; end
-end
-ChangeCollationForTagNames.class_eval do
- def up
- if ActsAsTaggableOn::Utils.using_mysql?
- execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
- end
- end
-end
diff --git a/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
deleted file mode 100644
index 7073df2a2..000000000
--- a/db/migrate/20190402083257_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# This migration comes from acts_as_taggable_on_engine (originally 6)
-if ActiveRecord.gem_version >= Gem::Version.new('5.0')
- class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
-else
- class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
-end
-AddMissingIndexesOnTaggings.class_eval do
- def change
- add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
- add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
- add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
- add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
- add_index :taggings, :context unless index_exists? :taggings, :context
-
- unless index_exists? :taggings, [:tagger_id, :tagger_type]
- add_index :taggings, [:tagger_id, :tagger_type]
- end
-
- unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
- add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
- end
- end
-end
diff --git a/db/migrate/20190403022053_create_gtask_banks.rb b/db/migrate/20190403022053_create_gtask_banks.rb
deleted file mode 100644
index f7c7b4ffb..000000000
--- a/db/migrate/20190403022053_create_gtask_banks.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class CreateGtaskBanks < ActiveRecord::Migration[5.2]
- def change
- create_table :gtask_banks do |t|
- t.references :user
- t.string :name
- t.text :description
- t.integer :task_type
- t.integer :min_num, default: 0
- t.integer :max_num, default: 0
- t.integer :base_on_project, default: false
- t.boolean :is_public, default: false
- t.integer :quotes, default: 0
- t.references :graduation_task
- t.references :course_list
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb b/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb
deleted file mode 100644
index a175d64e5..000000000
--- a/db/migrate/20190403025525_add_praises_count_for_jouranls_for_messages.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class AddPraisesCountForJouranlsForMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :journals_for_messages, :praises_count, :integer, :default => 0
-
- messages = JournalsForMessage.includes(:praise_treads).all
- messages.find_each do |m|
- puts("####{m.id}")
- praises_count = m.praise_treads.liker.count
- m.update_column(:praises_count, praises_count)
- end
-
- end
-end
diff --git a/db/migrate/20190403065609_create_gtopic_banks.rb b/db/migrate/20190403065609_create_gtopic_banks.rb
deleted file mode 100644
index a4e280252..000000000
--- a/db/migrate/20190403065609_create_gtopic_banks.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class CreateGtopicBanks < ActiveRecord::Migration[5.2]
- def change
- create_table :gtopic_banks do |t|
- t.references :user
- t.string :name
- t.text :description
- t.integer :quotes
- t.boolean :is_public
- t.integer :topic_type
- t.integer :topic_source
- t.integer :topic_property_first
- t.integer :topic_property_second
- t.string :source_unit
- t.integer :topic_repeat
- t.string :province
- t.string :city
- t.references :graduation_topic
- t.references :course_list
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb b/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb
deleted file mode 100644
index 8ed2a6f8c..000000000
--- a/db/migrate/20190408060723_add_is_ordered_to_exercise_standard_answers.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddIsOrderedToExerciseStandardAnswers < ActiveRecord::Migration[5.2]
- def change
- #试题的多空标准答案是否为一一对应,默认为一一对应,即true
- add_column :exercise_standard_answers,:is_ordered,:boolean,:default => true
- end
-end
diff --git a/db/migrate/20190410033511_change_column_in_homeworks.rb b/db/migrate/20190410033511_change_column_in_homeworks.rb
deleted file mode 100644
index df8da9b43..000000000
--- a/db/migrate/20190410033511_change_column_in_homeworks.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class ChangeColumnInHomeworks < ActiveRecord::Migration[5.2]
- def change
- change_column_default :homework_commons, :late_penalty, from: nil, to: 5
- change_column_default :homework_commons, :anonymous_comment, from: 0, to: 1
- change_column_default :homework_commons, :work_efficiency, from: 1, to: 0
- change_column_default :homework_commons, :eff_score, from: 20, to: 0
- change_column_default :homework_detail_manuals, :ta_proportion, from: nil, to: 0
- change_column_default :homework_detail_manuals, :comment_status, from: nil, to: 0
- change_column_default :homework_detail_manuals, :evaluation_num, from: nil, to: 0
- change_column_default :homework_detail_manuals, :absence_penalty, from: 1, to: 0
- end
-end
diff --git a/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb b/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb
deleted file mode 100644
index ae7144c4e..000000000
--- a/db/migrate/20190410081421_change_is_ordered_from_answer_to_question.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ChangeIsOrderedFromAnswerToQuestion < ActiveRecord::Migration[5.2]
- def change
- remove_column :exercise_standard_answers,:is_ordered
- add_column :exercise_questions,:is_ordered,:boolean,:default => true
- end
-end
diff --git a/db/migrate/20190410081736_migrate_homework_attachments.rb b/db/migrate/20190410081736_migrate_homework_attachments.rb
deleted file mode 100644
index fbdc26f6a..000000000
--- a/db/migrate/20190410081736_migrate_homework_attachments.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MigrateHomeworkAttachments < ActiveRecord::Migration[5.2]
- def change
- Attachment.where(container_type: "HomeworkCommon").update_all(attachtype: 1)
- end
-end
diff --git a/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb b/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb
deleted file mode 100644
index a2f9db27d..000000000
--- a/db/migrate/20190413011125_add_cloud_url_to_attachment_histories.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddCloudUrlToAttachmentHistories < ActiveRecord::Migration[5.2]
- def change
- add_column :attachment_histories, :cloud_url, :string, default: ''
- end
-end
diff --git a/db/migrate/20190415090426_change_homework_common_columns.rb b/db/migrate/20190415090426_change_homework_common_columns.rb
deleted file mode 100644
index 11360d47f..000000000
--- a/db/migrate/20190415090426_change_homework_common_columns.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class ChangeHomeworkCommonColumns < ActiveRecord::Migration[5.2]
- def up
- change_column :homework_commons, :score_open, :boolean, default: 1
- change_column :homework_commons, :anonymous_comment, :boolean, default: 1
- change_column :homework_commons, :anonymous_appeal, :boolean, default: 0
- end
-
- def down
- change_column :homework_commons, :score_open, :int, default: 1
- change_column :homework_commons, :anonymous_comment, :int, default: 1
- change_column :homework_commons, :anonymous_appeal, :int, default: 0
- end
-end
diff --git a/db/migrate/20190422032141_migrate_homework_late_time.rb b/db/migrate/20190422032141_migrate_homework_late_time.rb
deleted file mode 100644
index 342986b9c..000000000
--- a/db/migrate/20190422032141_migrate_homework_late_time.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class MigrateHomeworkLateTime < ActiveRecord::Migration[5.2]
- def change
- homeworks = HomeworkCommon.where.not(end_time: nil).where(homework_type: [1, 3 ,4], allow_late: 1, late_time: nil)
- homeworks.each do |homework|
- if homework.course.try(:end_date).present?
- homework.update_column("late_time", homework.course.end_date)
- elsif homework.end_time.present?
- homework.update_column("late_time", Time.at(homework.end_time.to_i + 30*24*3600))
- end
- end
-
- tasks = GraduationTask.where.not(end_time: nil).where(allow_late: 1, late_time: nil)
- tasks.each do |task|
- if task.course.try(:end_date).present?
- task.update_column("late_time", task.course.end_date)
- elsif task.end_time.present?
- task.update_column("late_time", Time.at(task.end_time.to_i + 30*24*3600))
- end
- end
- end
-end
diff --git a/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb b/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb
deleted file mode 100644
index 37162c850..000000000
--- a/db/migrate/20190422083020_add_journals_for_messages_count_for_hm_and_gt_and_gw.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class AddJournalsForMessagesCountForHmAndGtAndGw < ActiveRecord::Migration[5.2]
- def change
- #add_column :homework_commons, :journals_for_messages_count, :integer, :default => 0
- #add_column :graduation_tasks, :journals_for_messages_count, :integer, :default => 0
- #add_column :graduation_topics, :journals_for_messages_count, :integer, :default => 0
-
- type = ["GraduationTopic", "GraduationTask", "HomeworkCommon"]
- messages = JournalsForMessage.where(jour_type: type).where("m_parent_id is not null")
- # 迁移所有2级以上的回复
- messages.each do |message|
- while message.parent.try(:m_parent_id).present? do
- puts "parent: #{message.parent.try(:m_parent_id)}"
- message.update_attribute(:m_parent_id, message.parent.m_parent_id)
- end
- end
-
- end
-end
diff --git a/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb b/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb
deleted file mode 100644
index 21c20fcce..000000000
--- a/db/migrate/20190424014128_migrate_homework_anonymous_comment.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class MigrateHomeworkAnonymousComment < ActiveRecord::Migration[5.2]
- def change
- change_column_default :homework_commons, :anonymous_comment, from: 1, to: 0
-
- HomeworkCommon.update_all("anonymous_comment = !anonymous_comment")
- end
-end
diff --git a/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb b/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb
deleted file mode 100644
index 7b893db6d..000000000
--- a/db/migrate/20190426010412_add_is_invalid_to_student_works_scores.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class AddIsInvalidToStudentWorksScores < ActiveRecord::Migration[5.2]
- def change
- # add_column :student_works_scores, :is_invalid, :boolean, default: false
-
- StudentWorksScore.where("score is not null").order("id desc").find_each do |score|
- unless score.is_invalid
- if score.student_work.present?
- puts score.id
- work = score.student_work
-
- # 如果分数是调整分 则之前的所有分都无效
- if score.is_ultimate
- work.student_works_scores.where("score is not null and id < #{score.id}").update_all(is_invalid: 1)
-
- # 如果是同一个用户角色的重复评分,则之前的评分都无效
- elsif work.student_works_scores.where("user_id = #{score.user_id} and reviewer_role = #{score.reviewer_role}
- and score is not null and id < #{score.id}").count > 0
- work.student_works_scores.where("user_id = #{score.user_id} and reviewer_role = #{score.reviewer_role}
- and score is not null and id < #{score.id}").update_all(is_invalid: 1)
- end
- end
- end
- end
- end
-end
diff --git a/db/migrate/20190427010940_change_exercise_score_to_float.rb b/db/migrate/20190427010940_change_exercise_score_to_float.rb
deleted file mode 100644
index e8c57bc1e..000000000
--- a/db/migrate/20190427010940_change_exercise_score_to_float.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class ChangeExerciseScoreToFloat < ActiveRecord::Migration[5.2]
- def up
- change_column :exercise_users,:score,:decimal,precision: 10, scale: 1
- change_column :exercise_users, :objective_score, :decimal,precision: 10, scale: 1,default: 0.0
- # change_column :exercise_users, :subjective_score, :decimal,precision: 10, scale: 1,default: 0.0
- change_column :exercise_users, :subjective_score, :decimal,precision: 10, scale: 1,default: -1.0
- # change_column :exercise_answers,:score,:decimal,precision: 10, scale: 1,default: 0.0
- change_column :exercise_answers,:score,:decimal,precision: 10, scale: 1,default: -1.0 #6.10修改,方便判断主观题是否批阅
- change_column :exercise_bank_questions,:question_score,:decimal,precision: 10, scale: 1
- change_column :exercise_bank_shixun_challenges,:question_score,:decimal,precision: 10, scale: 1
- change_column :exercise_questions,:question_score,:decimal,precision: 10, scale: 1
- change_column :exercise_shixun_answers,:score,:decimal,precision: 10, scale: 1
- change_column :exercise_shixun_challenges,:question_score,:decimal,precision: 10, scale: 1
- change_column :exercise_answer_comments, :score,:decimal,precision: 10, scale: 1
- end
-
- def down
- change_column :exercise_users,:score,:integer
- change_column :exercise_users, :objective_score, :integer,default: -1
- change_column :exercise_users, :subjective_score, :integer,default: -1
- change_column :exercise_answers,:score,:integer,default: -1
- change_column :exercise_bank_questions,:question_score,:integer
- change_column :exercise_shixun_answers,:score,:integer
- change_column :exercise_bank_shixun_challenges,:question_score,:integer
- change_column :exercise_questions,:question_score,:integer
- change_column :exercise_shixun_challenges,:question_score,:integer
- change_column :exercise_answer_comments, :score,:integer
- end
-end
diff --git a/db/migrate/20190427045904_update_exercise_default_value.rb b/db/migrate/20190427045904_update_exercise_default_value.rb
deleted file mode 100644
index 05d76ee44..000000000
--- a/db/migrate/20190427045904_update_exercise_default_value.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class UpdateExerciseDefaultValue < ActiveRecord::Migration[5.2]
- def change
- ExerciseUser.where(objective_score: -1.0).update_all(objective_score: 0.0)
- # ExerciseUser.where(subjective_score: -1.0).update_all(subjective_score: 0.0) #主观题默认分数为-1,不需修改
- # ExerciseAnswer.where(score: -1.0).update_all(score: 0.0) #6.10 修改,方便判断主观题是否
- end
-end
diff --git a/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb b/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb
deleted file mode 100644
index d7c7e5b14..000000000
--- a/db/migrate/20190429012219_change_digest_to_string_in_attachment_histories.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ChangeDigestToStringInAttachmentHistories < ActiveRecord::Migration[5.2]
- def change
- change_column :attachment_histories, :digest, :string, :limit => 60
- end
-end
diff --git a/db/migrate/20190429015510_add_default_for_exercises.rb b/db/migrate/20190429015510_add_default_for_exercises.rb
deleted file mode 100644
index 3ebbf6e2f..000000000
--- a/db/migrate/20190429015510_add_default_for_exercises.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class AddDefaultForExercises < ActiveRecord::Migration[5.2]
- def change
- change_column :exercises, :exercise_status, :integer, :default => 1
- change_column :exercises, :show_result, :integer, :default => 1
- change_column :exercises, :time, :integer, :default => -1
- end
-end
diff --git a/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb b/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb
deleted file mode 100644
index 57694008e..000000000
--- a/db/migrate/20190429080104_add_quotes_for_graduation_topics.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddQuotesForGraduationTopics < ActiveRecord::Migration[5.2]
- def change
- add_column :graduation_topics, :quotes, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190430090659_add_default_for_polls.rb b/db/migrate/20190430090659_add_default_for_polls.rb
deleted file mode 100644
index 2fcb260ab..000000000
--- a/db/migrate/20190430090659_add_default_for_polls.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddDefaultForPolls < ActiveRecord::Migration[5.2]
- def change
- change_column :polls, :polls_status, :integer, :default => 1
- end
-end
diff --git a/db/migrate/20190505031946_sync_users_index.rb b/db/migrate/20190505031946_sync_users_index.rb
deleted file mode 100644
index a1f9b40fb..000000000
--- a/db/migrate/20190505031946_sync_users_index.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class SyncUsersIndex < ActiveRecord::Migration[5.2]
- def change
- remove_index :users, name: :index_users_on_phone_and_mail
- remove_index :users, name: :index_users_on_id_and_type
- remove_index :users, name: :index_users_on_auth_source_id
- remove_index :users, name: :index_users_on_type
- end
-end
diff --git a/db/migrate/20190505072404_remove_index_from_users.rb b/db/migrate/20190505072404_remove_index_from_users.rb
deleted file mode 100644
index b19219346..000000000
--- a/db/migrate/20190505072404_remove_index_from_users.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class RemoveIndexFromUsers < ActiveRecord::Migration[5.2]
- def change
- remove_index :users, name: :index_users_on_experience
- end
-end
diff --git a/db/migrate/20190505093440_init_use_index.rb b/db/migrate/20190505093440_init_use_index.rb
deleted file mode 100644
index b7c3101dd..000000000
--- a/db/migrate/20190505093440_init_use_index.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class InitUseIndex < ActiveRecord::Migration[5.2]
- def change
- remove_index :users, name: :index_users_on_login if index_exists?(:users, :login, name: :index_users_on_login)
- remove_index :users, name: :index_users_on_mail if index_exists?(:users, :mail, name: :index_users_on_mail)
- # add_index :users, :login, unique: true
- # add_index :users, :mail, unique: true
- # add_index :users, :phone, unique: true
- end
-end
diff --git a/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb b/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb
deleted file mode 100644
index 2cc1ba940..000000000
--- a/db/migrate/20190505095131_add_authentication_and_professional_certification_to_courses.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddAuthenticationAndProfessionalCertificationToCourses < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :authentication, :boolean, default: false
- add_column :courses, :professional_certification, :boolean, default: false
- end
-end
diff --git a/db/migrate/20190508090916_migrate_new_student_work_status.rb b/db/migrate/20190508090916_migrate_new_student_work_status.rb
deleted file mode 100644
index d2e9bb379..000000000
--- a/db/migrate/20190508090916_migrate_new_student_work_status.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class MigrateNewStudentWorkStatus < ActiveRecord::Migration[5.2]
- def change
- homeworks = HomeworkCommon.where(allow_late: 0)
- StudentWork.where(homework_common_id: homeworks, work_status: 2).update_all(work_status: 1)
- end
-end
diff --git a/db/migrate/20190511020736_add_is_public_to_messages.rb b/db/migrate/20190511020736_add_is_public_to_messages.rb
deleted file mode 100644
index bbbba8f50..000000000
--- a/db/migrate/20190511020736_add_is_public_to_messages.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIsPublicToMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :messages, :is_public, :boolean, :default => false
- end
-end
diff --git a/db/migrate/20190514023907_add_column_to_zip_packs.rb b/db/migrate/20190514023907_add_column_to_zip_packs.rb
deleted file mode 100644
index 8ba250f37..000000000
--- a/db/migrate/20190514023907_add_column_to_zip_packs.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class AddColumnToZipPacks < ActiveRecord::Migration[5.2]
- def change
- add_column :zip_packs, :container_id, :integer, default: 0
- add_column :zip_packs, :container_type, :string
-
- add_index :zip_packs, [:container_id, :container_type]
-
- ZipPack.all.update_all("container_type='HomeworkCommon', container_id = homework_id")
- end
-end
diff --git a/db/migrate/20190514083047_change_question_random_exercises.rb b/db/migrate/20190514083047_change_question_random_exercises.rb
deleted file mode 100644
index 313d648bb..000000000
--- a/db/migrate/20190514083047_change_question_random_exercises.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class ChangeQuestionRandomExercises < ActiveRecord::Migration[5.2]
- def up
- change_column :exercises,:question_random,:boolean,default: false
- change_column :exercises,:choice_random,:boolean,default: false
-
- end
- def down
- change_column :exercises,:question_random,:integer,default: 0
- change_column :exercises,:choice_random,:integer,default: 0
- end
-end
diff --git a/db/migrate/20190515014734_change_poll_show_result_boolean.rb b/db/migrate/20190515014734_change_poll_show_result_boolean.rb
deleted file mode 100644
index f74dd02c4..000000000
--- a/db/migrate/20190515014734_change_poll_show_result_boolean.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class ChangePollShowResultBoolean < ActiveRecord::Migration[5.2]
- def change
- def up
- change_column :polls,:show_result,:boolean,default: true
- end
- def down
- change_column :polls,:show_result,:integer,default: 1
- end
- end
-end
diff --git a/db/migrate/20190517080313_add_test_set_average_for_challenges.rb b/db/migrate/20190517080313_add_test_set_average_for_challenges.rb
deleted file mode 100644
index cac1d80bc..000000000
--- a/db/migrate/20190517080313_add_test_set_average_for_challenges.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddTestSetAverageForChallenges < ActiveRecord::Migration[5.2]
- def change
- add_column :challenges, :test_set_average, :boolean, :default => true
- end
-end
diff --git a/db/migrate/20190517085407_create_edu_settings.rb b/db/migrate/20190517085407_create_edu_settings.rb
deleted file mode 100644
index e6c081233..000000000
--- a/db/migrate/20190517085407_create_edu_settings.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class CreateEduSettings < ActiveRecord::Migration[5.2]
- def change
- create_table :edu_settings do |t|
- t.string :name
- t.string :value
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20190517092730_add_description_to_edu_settings.rb b/db/migrate/20190517092730_add_description_to_edu_settings.rb
deleted file mode 100644
index ad273b805..000000000
--- a/db/migrate/20190517092730_add_description_to_edu_settings.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class AddDescriptionToEduSettings < ActiveRecord::Migration[5.2]
- def change
- add_column :edu_settings, :description, :string
- add_index :edu_settings, :name, unique: :true
-
- ['tomcat_webssh', 'webssh_username', 'webssh_password', 'git_address_ip', 'git_address_domain', 'git_username',
- 'git_password', 'public_key', 'private_key', 'public_bucket', 'public_bucket_host', 'public_cdn_host', 'cloud_bridge',
- 'cloud_tomcat_php', 'host_name', 'old_edu_host'].each do |name|
- if EduSetting.find_by_name(name).nil?
- EduSetting.create(name: name)
- end
- end
- end
-end
diff --git a/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb b/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb
deleted file mode 100644
index e4bdaac19..000000000
--- a/db/migrate/20190518085626_add_index_to_verificatiojn_codes.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddIndexToVerificatiojnCodes < ActiveRecord::Migration[5.2]
- def change
- add_index :verification_codes, [:phone], name: 'by_phone' if !index_exists?(:verification_codes, :phone)
- add_index :verification_codes, [:email], name: 'by_email' if !index_exists?(:verification_codes, :email)
- end
-end
diff --git a/db/migrate/20190522091226_alter_educoder_indexs.rb b/db/migrate/20190522091226_alter_educoder_indexs.rb
deleted file mode 100644
index 6e1ed9bb5..000000000
--- a/db/migrate/20190522091226_alter_educoder_indexs.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-class AlterEducoderIndexs < ActiveRecord::Migration[5.2]
- def change
-
- add_index :onclick_times, :user_id if !index_exists?(:onclick_times, :user_id)
- remove_index :courses, :syllabus_id
- add_index :courses, :tea_id
- add_index :course_modules, [:course_id, :module_type]
- remove_index :homework_commons, :course_homework_category_id
- add_index :exercises, :course_id
- remove_index :teacher_course_groups, :member_id
- remove_index :student_works, :created_at
- remove_index :student_works, :user_id
- remove_index :student_works, :myshixun_id
- remove_index :homework_challenge_settings, :shixun_id
- remove_index :exercise_users, :exercise_id
- add_index :exercise_users, [:exercise_id, :user_id]
- add_index :homework_banks, :user_id
- remove_index :exercise_answers, :exercise_choice_id
- remove_index :exercise_answers, :exercise_question_id
- add_index :exercise_answers, [:exercise_question_id, :user_id]
- remove_index :exercise_shixun_challenges, :shixun_id
- remove_index :exercise_shixun_answers, :exercise_shixun_challenge_id
- remove_index :exercise_shixun_answers, :exercise_question_id
- add_index :exercise_shixun_answers, [:exercise_question_id, :user_id], name: "exercise_question_id_user_id"
- remove_index :student_works_evaluation_distributions, :student_work_id
- add_index :student_works_evaluation_distributions, :user_id
- remove_index :challenge_work_scores, :user_id
- add_index :poll_questions, :poll_id
- add_index :poll_users, [:poll_id, :user_id]
- add_index :poll_answers, :poll_question_id
- add_index :poll_votes, [:poll_question_id, :user_id], name: "poll_question_id_user_id"
- remove_index :graduation_tasks, :user_id
- remove_index :graduation_work_comment_assignations, :graduation_group_id
- remove_index :graduation_works, :course_id
- remove_index :graduation_works, :project_id
- remove_index :graduation_works, :graduation_task_id
- remove_index :graduation_works, :user_id
- add_index :graduation_works, [:graduation_task_id, :user_id], name: "graduation_task_id_user_id"
-
- remove_index :graduation_work_scores, :graduation_task_id
- remove_index :graduation_topics, :user_id
- remove_index :graduation_topics, :tea_id
- remove_index :student_graduation_topics, :member_id
- remove_index :student_graduation_topics, :course_member_id
- add_index :boards, :course_id
- remove_index :messages, :author_id
- remove_index :messages, :is_hidden
- remove_index :messages, :root_id
- remove_index :messages, :created_on
- remove_index :attachments, :quotes
- remove_index :attachments, :is_public
- remove_index :attachments, :course_second_category_id
- remove_index :course_members, :graduation_group_id
- add_index :student_works_scores_appeals, :student_works_score_id
- add_index :challenges, :shixun_id
- add_index :challenge_chooses, :challenge_id
- add_index :challenge_questions, :challenge_choose_id
- add_index :challenge_tags, :challenge_id
- remove_index :games, :user_id
- add_index :shixun_members, :shixun_id
- add_index :shixun_tag_repertoires, [:shixun_id, :tag_repertoire_id], name: "shixun_id_tag_repertoire_id"
- add_index :shixun_schools, :shixun_id
- add_index :shixun_mirror_repositories, :shixun_id
- add_index :shixun_modifies, [:shixun_id, :myshixun_id], name: "shixun_id_myshixun_id"
- remove_index :myshixuns, :user_id
- remove_index :outputs, :created_at
- remove_index :outputs, :test_set_position
- remove_index :stages, :user_id
- end
-end
diff --git a/db/migrate/20190524020819_change_exercise_question_type.rb b/db/migrate/20190524020819_change_exercise_question_type.rb
deleted file mode 100644
index 625a57d06..000000000
--- a/db/migrate/20190524020819_change_exercise_question_type.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class ChangeExerciseQuestionType < ActiveRecord::Migration[5.2]
- def change
- ExerciseQuestion.where(question_type: 1).update_all(question_type: 0) #新版0为单选题,1为多选题,2为判断题
- ExerciseQuestion.where(question_type: 2).update_all(question_type: 1)
-
- ExerciseBankQuestion.where(question_type: 1).update_all(question_type: 0)
- ExerciseBankQuestion.where(question_type: 2).update_all(question_type: 1)
-
- end
-end
diff --git a/db/migrate/20190528024055_migrate_base_on_project.rb b/db/migrate/20190528024055_migrate_base_on_project.rb
deleted file mode 100644
index d0ee197cb..000000000
--- a/db/migrate/20190528024055_migrate_base_on_project.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MigrateBaseOnProject < ActiveRecord::Migration[5.2]
- def change
- change_column :homework_detail_groups, :base_on_project, :boolean, default: true
- end
-end
diff --git a/db/migrate/20190603024856_migrate_course_late_settings.rb b/db/migrate/20190603024856_migrate_course_late_settings.rb
deleted file mode 100644
index 3097d3d34..000000000
--- a/db/migrate/20190603024856_migrate_course_late_settings.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class MigrateCourseLateSettings < ActiveRecord::Migration[5.2]
- def change
- change_column_default :homework_commons, :allow_late, from: 1, to: 0
- change_column_default :homework_commons, :late_penalty, from: 5, to: 0
-
- change_column_default :graduation_tasks, :allow_late, from: 1, to: 0
- change_column_default :graduation_tasks, :late_penalty, from: 5, to: 0
- end
-end
diff --git a/db/migrate/20190606061948_migrate_student_works_scores_score.rb b/db/migrate/20190606061948_migrate_student_works_scores_score.rb
deleted file mode 100644
index c531357a8..000000000
--- a/db/migrate/20190606061948_migrate_student_works_scores_score.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MigrateStudentWorksScoresScore < ActiveRecord::Migration[5.2]
- def change
- change_column :student_works_scores, :score, :float
- end
-end
diff --git a/db/migrate/20190610013620_change_question_random_default_true.rb b/db/migrate/20190610013620_change_question_random_default_true.rb
deleted file mode 100644
index d0c785d46..000000000
--- a/db/migrate/20190610013620_change_question_random_default_true.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class ChangeQuestionRandomDefaultTrue < ActiveRecord::Migration[5.2]
- #试卷的题目和选项的随机显示,需默认勾选
- def up
- change_column_default :exercises,:question_random,true
- change_column_default :exercises,:choice_random,true
- end
-
- def down
- change_column_default :exercises,:question_random,false
- change_column_default :exercises,:choice_random,false
- end
-end
diff --git a/db/migrate/20190613022158_add_exec_time_to_challenge.rb b/db/migrate/20190613022158_add_exec_time_to_challenge.rb
deleted file mode 100644
index c1743674c..000000000
--- a/db/migrate/20190613022158_add_exec_time_to_challenge.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddExecTimeToChallenge < ActiveRecord::Migration[5.2]
- def change
- add_column :challenges, :exec_time, :integer
-
- Shixun.find_each do |shixun|
- shixun.challenges.update_all(exec_time: shixun.exec_time)
- end
- end
-end
diff --git a/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb b/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb
deleted file mode 100644
index 2dbbb7146..000000000
--- a/db/migrate/20190617081105_change_default_data_for_name_in_borads.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class ChangeDefaultDataForNameInBorads < ActiveRecord::Migration[5.2]
- def change
- puts "--------- START ------------"
- Board.roots.joins(:course).where('courses.id = boards.course_id').find_each do |board|
- board.update_columns(name: '讨论区') unless board.name.strip === '讨论区'
- puts "Board ID IS #{board.id}"
- end
- puts "--------- END ----------"
- end
-end
diff --git a/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb b/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb
deleted file mode 100644
index 92ae6449f..000000000
--- a/db/migrate/20190619055012_add_uniq_index_to_course_modules.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-class AddUniqIndexToCourseModules < ActiveRecord::Migration[5.2]
- def change
- # sql = %Q(delete from exercise_users where (user_id, exercise_id) in
- # (select * from (select user_id, exercise_id from exercise_users group by user_id, exercise_id having count(*) > 1) a)
- # and id not in (select * from (select min(id) from exercise_users group by user_id, exercise_id having count(*) > 1 order by id) b))
- # ActiveRecord::Base.connection.execute sql
- #
- # add_index :exercise_users, [:user_id, :exercise_id], unique: true, name: "index_user_id_and_exercise_id"
-
-
- sql = %Q(delete from exercise_shixun_answers where (user_id, exercise_shixun_challenge_id) in
- (select * from (select user_id, exercise_shixun_challenge_id from exercise_shixun_answers group by user_id, exercise_shixun_challenge_id having count(*) > 1) a)
- and id not in (select * from (select min(id) from exercise_shixun_answers group by user_id, exercise_shixun_challenge_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
-
- add_index :exercise_shixun_answers, [:user_id, :exercise_shixun_challenge_id], unique: true,
- name: "index_user_id_and_exercise_shixun_challenge_id"
-
-
- # sql = %Q(delete from student_works where (user_id, homework_common_id) in
- # (select * from (select user_id, homework_common_id from student_works group by user_id, homework_common_id having count(*) > 1) a)
- # and id not in (select * from (select min(id) from student_works group by user_id, homework_common_id having count(*) > 1 order by id) b))
- # ActiveRecord::Base.connection.execute sql
- #
- # add_index :student_works, [:user_id, :homework_common_id], unique: true, name: "index_user_id_and_homework_common_id"
- #
- #
- # sql = %Q(delete from poll_users where (user_id, poll_id) in
- # (select * from (select user_id, poll_id from poll_users group by user_id, poll_id having count(*) > 1) a) and
- # id not in (select * from (select min(id) from poll_users group by user_id, poll_id having count(*) > 1 order by id) b))
- # ActiveRecord::Base.connection.execute sql
- #
- # add_index :poll_users, [:user_id, :poll_id], unique: true, name: "index_user_id_and_poll_id"
- #
- #
- # sql = %Q(delete from graduation_works where (user_id, graduation_task_id) in
- # (select * from (select user_id, graduation_task_id from graduation_works group by user_id, graduation_task_id having count(*) > 1) a) and
- # id not in (select * from (select min(id) from graduation_works group by user_id, graduation_task_id having count(*) > 1 order by id) b))
- # ActiveRecord::Base.connection.execute sql
- #
- # add_index :graduation_works, [:user_id, :graduation_task_id], unique: true, name: "index_user_id_and_graduation_task_id"
- end
-end
diff --git a/db/migrate/20190619093200_add_profile_completed_to_users.rb b/db/migrate/20190619093200_add_profile_completed_to_users.rb
deleted file mode 100644
index 5248abd58..000000000
--- a/db/migrate/20190619093200_add_profile_completed_to_users.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddProfileCompletedToUsers < ActiveRecord::Migration[5.2]
- def change
- add_column :users, :profile_completed, :boolean, default: false
- end
-end
diff --git a/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb b/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb
deleted file mode 100644
index 01444b7ce..000000000
--- a/db/migrate/20190619120609_add_graduation_topics_count_to_course.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddGraduationTopicsCountToCourse < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :graduation_topics_count, :integer, :default => 0
- add_column :courses, :graduation_tasks_count, :integer, :default => 0
- # add_column :courses, :attachments_count, :integer, :default => 0
- add_column :courses, :polls_count, :integer, :default => 0
- add_column :courses, :exercises_count, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190619123328_sync_countcha_for_course.rb b/db/migrate/20190619123328_sync_countcha_for_course.rb
deleted file mode 100644
index acd9e9716..000000000
--- a/db/migrate/20190619123328_sync_countcha_for_course.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class SyncCountchaForCourse < ActiveRecord::Migration[5.2]
- def change
- Course.find_each do |course|
- Course.reset_counters course.id, :graduation_topics
- Course.reset_counters course.id, :graduation_tasks
- Course.reset_counters course.id, :polls
- Course.reset_counters course.id, :exercises
- # Course.reset_counters course.id, :attachments
- end
- end
-end
diff --git a/db/migrate/20190620010439_add_uniq_index_to_course_member.rb b/db/migrate/20190620010439_add_uniq_index_to_course_member.rb
deleted file mode 100644
index f17cd4274..000000000
--- a/db/migrate/20190620010439_add_uniq_index_to_course_member.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class AddUniqIndexToCourseMember < ActiveRecord::Migration[5.2]
- def change
- # sql = %Q(delete from course_members where (user_id, course_id, role) in
- # (select * from (select user_id, course_id, role from course_members group by user_id, course_id, role having count(*) > 1) a)
- # and id not in (select * from (select min(id) from course_members group by user_id, course_id, role having count(*) > 1 order by id) b))
- # ActiveRecord::Base.connection.execute sql
- #
- # add_index :course_members, [:user_id, :course_id, :role], unique: true, name: "index_user_id_course_id_role"
- end
-end
diff --git a/db/migrate/20190620015912_modify_colla_index.rb b/db/migrate/20190620015912_modify_colla_index.rb
deleted file mode 100644
index 0e9e23301..000000000
--- a/db/migrate/20190620015912_modify_colla_index.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-class ModifyCollaIndex < ActiveRecord::Migration[5.2]
- def change
- remove_index :exercise_users, [:user_id, :exercise_id] if index_exists?(:exercise_users, [:user_id, :exercise_id])
- remove_index :exercise_users, [:exercise_id, :user_id] if index_exists?(:exercise_users, [:exercise_id, :user_id])
- sql = %Q(delete from exercise_users where (user_id, exercise_id) in
- (select * from (select user_id, exercise_id from exercise_users group by user_id, exercise_id having count(*) > 1) a)
- and id not in (select * from (select min(id) from exercise_users group by user_id, exercise_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :exercise_users, [:exercise_id, :user_id], unique: true, name: "index_on_exercise_id_user_id"
-
-
- remove_index :exercise_shixun_answers, :user_id
-
-
- remove_index :student_works, [:user_id, :homework_common_id] if index_exists?(:student_works, [:user_id, :homework_common_id])
- remove_index :student_works, [:homework_common_id, :user_id] if index_exists?(:student_works, [:homework_common_id, :user_id])
- sql = %Q(delete from student_works where (user_id, homework_common_id) in
- (select * from (select user_id, homework_common_id from student_works group by user_id, homework_common_id having count(*) > 1) a)
- and id not in (select * from (select min(id) from student_works group by user_id, homework_common_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :student_works, [:homework_common_id, :user_id], unique: true, name: "index_on_homework_common_id_user_id"
-
-
- remove_index :poll_users, [:user_id, :poll_id] if index_exists?(:poll_users, [:user_id, :poll_id])
- remove_index :poll_users, [:poll_id, :user_id] if index_exists?(:poll_users, [:poll_id, :user_id])
- sql = %Q(delete from poll_users where (user_id, poll_id) in
- (select * from (select user_id, poll_id from poll_users group by user_id, poll_id having count(*) > 1) a) and
- id not in (select * from (select min(id) from poll_users group by user_id, poll_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :poll_users, [:poll_id, :user_id], unique: true, name: "index_poll_id_and_user_id"
-
-
- remove_index :graduation_works, [:user_id, :graduation_task_id] if index_exists?(:graduation_works, [:user_id, :graduation_task_id])
- remove_index :graduation_works, [:graduation_task_id, :user_id] if index_exists?(:graduation_works, [:graduation_task_id, :user_id])
- sql = %Q(delete from graduation_works where (user_id, graduation_task_id) in
- (select * from (select user_id, graduation_task_id from graduation_works group by user_id, graduation_task_id having count(*) > 1) a) and
- id not in (select * from (select min(id) from graduation_works group by user_id, graduation_task_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :graduation_works, [:graduation_task_id, :user_id], unique: true, name: "index_graduation_task_id_and_user_id"
-
-
- remove_index :course_members, [:user_id, :course_id, :role] if index_exists?(:course_members, [:user_id, :course_id, :role])
- remove_index :course_members, :course_id if index_exists?(:course_members, :course_id)
- remove_index :course_members, :user_id if index_exists?(:course_members, :user_id)
- sql = %Q(delete from course_members where (course_id, user_id, role) in
- (select * from (select course_id, user_id, role from course_members group by course_id, user_id, role having count(*) > 1) a)
- and id not in (select * from (select min(id) from course_members group by course_id, user_id, role having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :course_members, [:course_id, :user_id, :role], unique: true, name: "index_course_id_user_id_role"
- end
-end
diff --git a/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb b/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb
deleted file mode 100644
index 9a97b82bf..000000000
--- a/db/migrate/20190620021243_add_homework_bank_id_index_to_homework_commons.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddHomeworkBankIdIndexToHomeworkCommons < ActiveRecord::Migration[5.2]
- def change
- add_index :homework_commons, :homework_bank_id
- end
-end
diff --git a/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb b/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb
deleted file mode 100644
index 8149731e7..000000000
--- a/db/migrate/20190620075503_add_bank_id_for_graduation_task_and_topic.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddBankIdForGraduationTaskAndTopic < ActiveRecord::Migration[5.2]
- def change
- add_column :graduation_tasks, :gtask_bank_id, :integer
- add_column :graduation_topics, :gtopic_bank_id, :integer
- end
-end
diff --git a/db/migrate/20190621010002_change_default_to_max_num.rb b/db/migrate/20190621010002_change_default_to_max_num.rb
deleted file mode 100644
index 435756cd8..000000000
--- a/db/migrate/20190621010002_change_default_to_max_num.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ChangeDefaultToMaxNum < ActiveRecord::Migration[5.2]
- def change
- change_column :graduation_tasks, :max_num, :integer, default: 5
- end
-end
diff --git a/db/migrate/20190621062948_migrate_course_module_activity.rb b/db/migrate/20190621062948_migrate_course_module_activity.rb
deleted file mode 100644
index 1fa1ea112..000000000
--- a/db/migrate/20190621062948_migrate_course_module_activity.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MigrateCourseModuleActivity < ActiveRecord::Migration[5.2]
- def change
- CourseModule.where(module_type: 'activity').update_all(hidden: 1)
- end
-end
\ No newline at end of file
diff --git a/db/migrate/20190621083604_add_descendants_count_to_messages.rb b/db/migrate/20190621083604_add_descendants_count_to_messages.rb
deleted file mode 100644
index 02b721583..000000000
--- a/db/migrate/20190621083604_add_descendants_count_to_messages.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddDescendantsCountToMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :messages, :descendants_count, :integer, default: 0
- end
-end
diff --git a/db/migrate/20190621105144_sync_ivalid_users.rb b/db/migrate/20190621105144_sync_ivalid_users.rb
deleted file mode 100644
index f2875977f..000000000
--- a/db/migrate/20190621105144_sync_ivalid_users.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-class SyncIvalidUsers < ActiveRecord::Migration[5.2]
- # def change
- # users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, login from users group by login having user_count>1")
- # users.each do |user|
- # valid_users = User.where(login: user.login)
- # valid_users.each do |valid_user|
- # unless valid_user.lastname.present?
- # valid_user.delete
- # end
- # end
- # end
- #
- # mail_users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, mail from users where mail is not null group by mail having user_count>1")
- # mail_users.each do |mail_user|
- # valid_mail_users = User.where(mail: mail_user.mail)
- # valid_mail_users.each do |valid_mail_user|
- # unless valid_mail_user.lastname.present?
- # valid_mail_user.delete
- # end
- # end
- # end
- #
- #
- # phone_users = User.where.not(id: 2).find_by_sql("select count(*) as user_count, phone from users where phone is not null group by phone having user_count>1")
- # phone_users.each do |phone_user|
- # valid_phone_users = User.where(phone: phone_user.phone)
- # valid_phone_users.each do |valid_phone_user|
- # unless valid_phone_user.lastname.present?
- # valid_phone_user.delete
- # end
- # end
- # end
- # end
-end
diff --git a/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb b/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb
deleted file mode 100644
index 1a3aa147b..000000000
--- a/db/migrate/20190622055449_modify_shixun_info_for_shixuns.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class ModifyShixunInfoForShixuns < ActiveRecord::Migration[5.2]
- def change
- Shixun.find_each do |shixun|
- if shixun.shixun_info
- shixun.shixun_info.update_attributes(propaedeutics: shixun[:propaedeutics],
- description: shixun[:description],
- evaluate_script: shixun[:evaluate_script],
- shixun_id: shixun[:id])
- else
- ShixunInfo.create!(propaedeutics: shixun[:propaedeutics], description: shixun[:description],
- evaluate_script: shixun[:evaluate_script], shixun_id: shixun.id)
- end
- end
- end
-end
diff --git a/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb b/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb
deleted file mode 100644
index 4557c610f..000000000
--- a/db/migrate/20190622060005_remove_shixun_long_text_for_shixuns.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class RemoveShixunLongTextForShixuns < ActiveRecord::Migration[5.2]
- def change
- if Shixun.first.has_attribute?(:description)
- remove_columns :shixuns, :description, :propaedeutics, :evaluate_script
- end
- end
-end
diff --git a/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb b/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb
deleted file mode 100644
index 49a385ad9..000000000
--- a/db/migrate/20190624085120_add_uniq_index_to_homework_challenge_settings.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class AddUniqIndexToHomeworkChallengeSettings < ActiveRecord::Migration[5.2]
- def change
- remove_index :homework_challenge_settings, [:homework_common_id, :challenge_id] if index_exists?(:homework_challenge_settings, [:homework_common_id, :challenge_id])
- sql = %Q(delete from homework_challenge_settings where (homework_common_id, challenge_id) in
- (select * from (select homework_common_id, challenge_id from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1) a)
- and id not in (select * from (select max(id) from homework_challenge_settings group by homework_common_id, challenge_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :homework_challenge_settings, [:homework_common_id, :challenge_id], unique: true, name: "index_on_homework_common_id_challenge_id"
- end
-end
diff --git a/db/migrate/20190625012548_add_index_for_evaluate_record.rb b/db/migrate/20190625012548_add_index_for_evaluate_record.rb
deleted file mode 100644
index d67e33b1e..000000000
--- a/db/migrate/20190625012548_add_index_for_evaluate_record.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddIndexForEvaluateRecord < ActiveRecord::Migration[5.2]
- def change
- # 增加evalute_records的索引,提高查询效率
- add_index :evaluate_records, :game_id
- end
-end
diff --git a/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb b/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb
deleted file mode 100644
index a47157414..000000000
--- a/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ModifyQuotesForGtopicBanks < ActiveRecord::Migration[5.2]
- def change
- GtopicBank.where("quotes is null").update_all(:quotes => 0)
- change_column :gtopic_banks, :quotes, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190701013243_add_calculation_time_to_homework.rb b/db/migrate/20190701013243_add_calculation_time_to_homework.rb
deleted file mode 100644
index 4a622ee92..000000000
--- a/db/migrate/20190701013243_add_calculation_time_to_homework.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class AddCalculationTimeToHomework < ActiveRecord::Migration[5.2]
- def change
- add_column :homework_commons, :calculation_time, :datetime
- add_column :student_works, :calculation_time, :datetime
- end
-end
diff --git a/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb b/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb
deleted file mode 100644
index 9ad1429e2..000000000
--- a/db/migrate/20190703072611_add_old_exercise_tiankong_choice_id.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class AddOldExerciseTiankongChoiceId < ActiveRecord::Migration[5.2]
-
- def up
- #类型为3 的问题答案及标准答案更新exercise_choice_id 为1,即表示第一空
- exercise_question_ids = ExerciseQuestion.where("question_type = 3").pluck(:id)
- ExerciseAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: nil).update_all(exercise_choice_id:1)
- ExerciseStandardAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: nil).update_all(exercise_choice_id:1)
-
- exercise_bank_question_ids = ExerciseBankQuestion.where("question_type =3").pluck(:id)
- ExerciseBankStandardAnswer.where(exercise_bank_question_id: exercise_bank_question_ids).update_all(exercise_bank_choice_id:1)
- end
-
- def down
- #类型为3 的问题答案及标准答案更新exercise_choice_id 为1,即表示第一空
- exercise_question_ids = ExerciseQuestion.where("question_type = 3").pluck(:id)
- ExerciseAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: 1).update_all(exercise_choice_id:nil)
- ExerciseStandardAnswer.where(exercise_question_id: exercise_question_ids,exercise_choice_id: 1).update_all(exercise_choice_id:nil)
-
- exercise_bank_question_ids = ExerciseBankQuestion.where("question_type =3").pluck(:id)
- ExerciseBankStandardAnswer.where(exercise_bank_question_id: exercise_bank_question_ids).update_all(exercise_bank_choice_id:nil)
- end
-
-end
diff --git a/db/migrate/20190703090511_add_index_for_shixun_services.rb b/db/migrate/20190703090511_add_index_for_shixun_services.rb
deleted file mode 100644
index 693add3e3..000000000
--- a/db/migrate/20190703090511_add_index_for_shixun_services.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddIndexForShixunServices < ActiveRecord::Migration[5.2]
- def change
- sql = %Q(delete from shixun_service_configs where (shixun_id, mirror_repository_id) in
- (select * from (select shixun_id, mirror_repository_id from shixun_service_configs group by shixun_id, mirror_repository_id having count(*) > 1) a)
- and id not in (select * from (select min(id) from shixun_service_configs group by shixun_id, mirror_repository_id having count(*) > 1 order by id) b))
- ActiveRecord::Base.connection.execute sql
- add_index :shixun_service_configs, [:shixun_id, :mirror_repository_id], unique: true, name: "shixun_id_mirror_id_unique"
- end
-end
diff --git a/db/migrate/20190705011739_add_praises_count_for_challenges.rb b/db/migrate/20190705011739_add_praises_count_for_challenges.rb
deleted file mode 100644
index 6ae1d8420..000000000
--- a/db/migrate/20190705011739_add_praises_count_for_challenges.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddPraisesCountForChallenges < ActiveRecord::Migration[5.2]
- def change
- add_column :challenges, :praises_count, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190705013204_modify_praises_count_for_challenges.rb b/db/migrate/20190705013204_modify_praises_count_for_challenges.rb
deleted file mode 100644
index 59aa6ca53..000000000
--- a/db/migrate/20190705013204_modify_praises_count_for_challenges.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ModifyPraisesCountForChallenges < ActiveRecord::Migration[5.2]
- def change
- challenges = Challenge.where(nil).unscoped
- challenges.find_each do |c|
- praises_count = c.praise_treads.where(praise_or_tread: 1).count
- c.update_column(:praises_count, praises_count)
- end
- end
-end
diff --git a/db/migrate/20190705022502_add_praises_count_for_discuess.rb b/db/migrate/20190705022502_add_praises_count_for_discuess.rb
deleted file mode 100644
index 47fd5ec1a..000000000
--- a/db/migrate/20190705022502_add_praises_count_for_discuess.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddPraisesCountForDiscuess < ActiveRecord::Migration[5.2]
- def change
- add_column :discusses, :praises_count, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190705022737_modify_praises_count_for_discuess.rb b/db/migrate/20190705022737_modify_praises_count_for_discuess.rb
deleted file mode 100644
index 4d5b6ca97..000000000
--- a/db/migrate/20190705022737_modify_praises_count_for_discuess.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ModifyPraisesCountForDiscuess < ActiveRecord::Migration[5.2]
- def change
- discusses = Discuss.includes(:praise_treads).unscoped
- discusses.find_each do |d|
- praises_count = d.praise_treads.liker.count
- d.update_column(:praises_count, praises_count)
- end
- end
-end
diff --git a/db/migrate/20190705085829_add_sec_key_to_outputs.rb b/db/migrate/20190705085829_add_sec_key_to_outputs.rb
deleted file mode 100644
index 1da2930ae..000000000
--- a/db/migrate/20190705085829_add_sec_key_to_outputs.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class AddSecKeyToOutputs < ActiveRecord::Migration[5.2]
- def change
- #add_column :outputs, :sec_key, :string
- # add_column :outputs, :ts_mem, :float
- # add_column :outputs, :ts_time, :float
- end
-end
diff --git a/db/migrate/20190706010307_create_user_interests.rb b/db/migrate/20190706010307_create_user_interests.rb
deleted file mode 100644
index d64a1c228..000000000
--- a/db/migrate/20190706010307_create_user_interests.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class CreateUserInterests < ActiveRecord::Migration[5.2]
- def change
- create_table :user_interests do |t|
- t.references :user
- t.references :repertoire
- end
- end
-end
diff --git a/db/migrate/20190708062910_add_index_for_run_code_message.rb b/db/migrate/20190708062910_add_index_for_run_code_message.rb
deleted file mode 100644
index 4449d58a2..000000000
--- a/db/migrate/20190708062910_add_index_for_run_code_message.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIndexForRunCodeMessage < ActiveRecord::Migration[5.2]
- def change
- add_index :run_code_messages, :game_id
- end
-end
diff --git a/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb b/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb
deleted file mode 100644
index 86052375b..000000000
--- a/db/migrate/20190711062033_modify_challenge_id_for_discusses.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class ModifyChallengeIdForDiscusses < ActiveRecord::Migration[5.2]
- def change
- discusses = Discuss.where(challenge_id: nil)
- discusses.each do |dis|
- challenge_id = Shixun.find(dis.dis_id).challenges.first.id
- dis.update_column(:challenge_id, challenge_id)
- end
- add_index :discusses, :challenge_id
-
- end
-end
diff --git a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb b/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb
deleted file mode 100644
index 10b821fc5..000000000
--- a/db/migrate/20190713022300_modify_md_attachment_url_for_md_cotents.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-class ModifyMdAttachmentUrlForMdCotents < ActiveRecord::Migration[5.2]
- def change
- # 更新MarkDown图片的URL
- homework_commons = HomeworkCommon.all
- homework_commons.find_each do |hc|
- hc.update_column(:description, hc.description.gsub(") if hc.description.present?
- end
-
- challenges = Challenge.all.unscoped
- challenges.find_each do |c|
- c.update_column(:task_pass, c.task_pass.gsub(") if c.task_pass.present?
- end
-
- challenge_answers = ChallengeAnswer.all.unscoped
- challenge_answers.find_each do |ca|
- ca.update_column(:contents, ca.contents.gsub(") if ca.contents.present?
- end
-
- shixun_infos = ShixunInfo.all
- shixun_infos.find_each do |si|
- si.update_column(:propaedeutics, si.propaedeutics.gsub(") if si.propaedeutics.present?
- si.update_column(:description, si.description.gsub(") if si.description.present?
- end
-
- subjects = Subject.all
- subjects.find_each do |s|
- s.update_column(:description, s.description.gsub(") if s.description.present?
- end
-
- plats = PlatformSample.where(samples_type: ['introduction', 'knowledge'])
- plats.find_each do |p|
- p.update_column(:contents, p.contents.gsub(") if p.contents.present?
- end
- end
-end
diff --git a/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb b/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb
deleted file mode 100644
index 86425262d..000000000
--- a/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddMaxMemToEvaluateRecords < ActiveRecord::Migration[5.2]
- def change
- #add_column :evaluate_records, :max_mem, :float
- end
-end
diff --git a/db/migrate/20190720025309_add_ts_mem_for_outputs.rb b/db/migrate/20190720025309_add_ts_mem_for_outputs.rb
deleted file mode 100644
index fac886fda..000000000
--- a/db/migrate/20190720025309_add_ts_mem_for_outputs.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddTsMemForOutputs < ActiveRecord::Migration[5.2]
- def change
- #add_column :outputs, :ts_mem, :float
- end
-end
diff --git a/db/migrate/20190720025341_add_ts_time_for_outputs.rb b/db/migrate/20190720025341_add_ts_time_for_outputs.rb
deleted file mode 100644
index 9c5f8a23f..000000000
--- a/db/migrate/20190720025341_add_ts_time_for_outputs.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddTsTimeForOutputs < ActiveRecord::Migration[5.2]
- def change
- #add_column :outputs, :ts_time, :float
- end
-end
diff --git a/db/migrate/20190720121537_add_is_md_for_messages.rb b/db/migrate/20190720121537_add_is_md_for_messages.rb
deleted file mode 100644
index a801fb387..000000000
--- a/db/migrate/20190720121537_add_is_md_for_messages.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddIsMdForMessages < ActiveRecord::Migration[5.2]
- def change
- add_column :messages, :is_md, :boolean, :default => true
- end
-end
diff --git a/db/migrate/20190720122123_modify_is_md_for_messages.rb b/db/migrate/20190720122123_modify_is_md_for_messages.rb
deleted file mode 100644
index 4137fc8af..000000000
--- a/db/migrate/20190720122123_modify_is_md_for_messages.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class ModifyIsMdForMessages < ActiveRecord::Migration[5.2]
- def change
- Message.find_each do |m|
- m.update_column(:is_md, false)
- end
- end
-end
diff --git a/db/migrate/20190722062801_modify_answer_for_challenges.rb b/db/migrate/20190722062801_modify_answer_for_challenges.rb
deleted file mode 100644
index 747564d68..000000000
--- a/db/migrate/20190722062801_modify_answer_for_challenges.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class ModifyAnswerForChallenges < ActiveRecord::Migration[5.2]
- def change
- challenges = Challenge.where("answer is not null or answer != ''")
- .includes(:challenge_answers).unscoped
- challenges.find_each do |c|
- next if c.challenge_answers.present?
- puts("############challenge_id:##{c.id}")
- ChallengeAnswer.create(name: "解题代码", contents: "#{c.answer}", level: 1, score: 100, challenge_id: c.id)
- end
- end
-end
diff --git a/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb b/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb
deleted file mode 100644
index a85152894..000000000
--- a/db/migrate/20190723152256_delete_contents_is_null_for_challenge_answers.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class DeleteContentsIsNullForChallengeAnswers < ActiveRecord::Migration[5.2]
- def change
- contents = ChallengeAnswer.where("contents = ''")
- contents.delete_all
- end
-end
diff --git a/db/migrate/20190724013024_modify_final_score_for_games.rb b/db/migrate/20190724013024_modify_final_score_for_games.rb
deleted file mode 100644
index e926cccd6..000000000
--- a/db/migrate/20190724013024_modify_final_score_for_games.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class ModifyFinalScoreForGames < ActiveRecord::Migration[5.2]
- def change
- grades = Grade.where(container_type: "Answer")
- grades.each do |grade|
- g = Game.find_by_id(grade.container_id)
- if g.present?
- if g.status == 2 && g.answer_open > 0 && g.final_score <= 0 && g.end_time < grade.created_at
- g.update_column(:final_score, g.challenge.score)
- elsif g.final_score < 0
- g.update_column(:final_score, 0)
- end
- end
- end
- end
-end
diff --git a/db/migrate/20190726082937_add_is_md_for_homeworks.rb b/db/migrate/20190726082937_add_is_md_for_homeworks.rb
deleted file mode 100644
index 0b25dde97..000000000
--- a/db/migrate/20190726082937_add_is_md_for_homeworks.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class AddIsMdForHomeworks < ActiveRecord::Migration[5.2]
- def change
- # add_column :homework_commons, :is_md, :boolean, :default => true
- # add_column :homework_banks, :is_md, :boolean, :default => true
- #
- #
- # add_column :exercise_questions,:is_md, :boolean, :default => true
- # add_column :poll_questions,:is_md, :boolean, :default => true
- #
- # add_column :exercise_bank_questions, :is_md, :boolean, :default => true
- end
-end
diff --git a/db/migrate/20190726083814_migrate_course_is_md.rb b/db/migrate/20190726083814_migrate_course_is_md.rb
deleted file mode 100644
index 6988db14a..000000000
--- a/db/migrate/20190726083814_migrate_course_is_md.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class MigrateCourseIsMd < ActiveRecord::Migration[5.2]
- def change
- # HomeworkCommon.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
- # HomeworkBank.where(homework_type: [1, 3]).where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
- #
- # HomeworkCommon.where(homework_type: [1, 3]).where("created_at >= '2019-07-21 00:00:00' and homework_bank_id is not null").each do |homework|
- #
- # end
- #
- # ExerciseQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
- # PollQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
- # ExerciseBankQuestion.where("created_at < '2019-07-21 00:00:00'").update_all(is_md: false)
- end
-end
diff --git a/db/migrate/20190729080935_modify_login_for_users.rb b/db/migrate/20190729080935_modify_login_for_users.rb
deleted file mode 100644
index 60e5e0964..000000000
--- a/db/migrate/20190729080935_modify_login_for_users.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ModifyLoginForUsers < ActiveRecord::Migration[5.2]
- def change
- users = User.where("created_on > '2019-07-26 19:00:00'")
- users.find_each do |use|
- use.update_attributes(login: use.login&.strip, phone: use.phone&.strip)
- use.user_extension.update_column(:student_id, use.user_extension&.student_id&.strip) if use.user_extension
- end
- end
-end
diff --git a/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb b/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb
deleted file mode 100644
index ef5b86975..000000000
--- a/db/migrate/20190729095722_delete_error_myshixun_from_myshxiuns.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class DeleteErrorMyshixunFromMyshxiuns < ActiveRecord::Migration[5.2]
- def change
- myshixuns = Myshixun.where("created_at > '2019-07-26 00:00:00' and repo_name is null")
- myshixuns.find_each do |myshixun|
- if myshixun.games.blank?
- puts("###########user_login: #{User.find(myshixun.user_id).login}")
- myshixun.destroy!
- end
- end
- end
-end
diff --git a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb b/db/migrate/20190729122213_delete_myshixun_games_for_users.rb
deleted file mode 100644
index d52369828..000000000
--- a/db/migrate/20190729122213_delete_myshixun_games_for_users.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class DeleteMyshixunGamesForUsers < ActiveRecord::Migration[5.2]
- def change
- myshixuns = Myshixun.where("created_at > '2019-07-26 19:00:00' and repo_name is null")
- myshixuns.find_each do |m|
- if m.games.count == m.games.select{|g| g.status == 3}.count
- puts("#######login: #{User.find(m.user_id).login}")
- m.destroy!
- end
- end
- end
-end
diff --git a/db/migrate/20190801075337_add_praises_count_to_memos.rb b/db/migrate/20190801075337_add_praises_count_to_memos.rb
deleted file mode 100644
index 0cc2259e2..000000000
--- a/db/migrate/20190801075337_add_praises_count_to_memos.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class AddPraisesCountToMemos < ActiveRecord::Migration[5.2]
- def change
- add_column :memos, :praises_count, :integer, :default => 0
-
- memos = Memo.includes(:praise_treads).all
- memos.find_each do |m|
- puts("####{m.id}")
- praises_count = m.praise_treads.select{|pt| pt.praise_or_tread == 1}.count
- m.update_column(:praises_count, praises_count)
- end
- end
-end
diff --git a/db/migrate/20190801084533_add_praises_count_to_libraries.rb b/db/migrate/20190801084533_add_praises_count_to_libraries.rb
deleted file mode 100644
index b773cf918..000000000
--- a/db/migrate/20190801084533_add_praises_count_to_libraries.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class AddPraisesCountToLibraries < ActiveRecord::Migration[5.2]
- def change
- # add_column :libraries, :praises_count, :integer, :default => 0
- #
- # Library.find_each do |library|
- # praises_count = library.praise_treads.count
- # library.update_column(:praises_count, praises_count)
- # end
- end
-end
diff --git a/db/migrate/20190802105008_tranfer_tiding_data.rb b/db/migrate/20190802105008_tranfer_tiding_data.rb
deleted file mode 100644
index ef7682530..000000000
--- a/db/migrate/20190802105008_tranfer_tiding_data.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class TranferTidingData < ActiveRecord::Migration[5.2]
- def change
- Tiding.where(container_type: 'ApplyAddSchool').update_all(container_type: 'ApplyAddSchools')
- end
-end
diff --git a/db/migrate/20190805004505_sync_index_to_users.rb b/db/migrate/20190805004505_sync_index_to_users.rb
deleted file mode 100644
index 33adca30c..000000000
--- a/db/migrate/20190805004505_sync_index_to_users.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class SyncIndexToUsers < ActiveRecord::Migration[5.2]
- def change
- add_index :users, :login, unique: true
- add_index :users, :mail, unique: true
- add_index :users, :phone, unique: true
- end
-end
diff --git a/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb b/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb
deleted file mode 100644
index 958b70448..000000000
--- a/db/migrate/20190805010562_modify_ke_contents_for_markdown.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
- include ActionView::Helpers::SanitizeHelper
- def change
- # def ke_transform_to_md content
- # return content if content.blank?
- # s_contents = sanitize(content, tags: %w(img a table td tr tbody pre), attributes: %w(src href target style))
- # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "
")
- # .gsub("\t", "").gsub("\n", "").gsub(" ", " ").gsub(/(
)+/, "
")
- # s_contents.gsub("\n", "
").gsub(/(
)+/, "
")
- # end
- #
- # # 课程讨论区
- # MessageDetail.find_each do |m|
- # content = ke_transform_to_md m.content
- # m.update_column(:content, content)
- # end
-
- #试卷的标题
- # ExerciseQuestion.where(:exercise_id => 1892).find_each do |eq|
- # puts("#eq.question_title: #{eq.question_title}")
- # question_title = ke_transform_to_md eq.question_title
- # puts("#question_title: #{question_title}")
- # eq.update_column(:question_title, question_title)
- # end
-
- # # 试卷的答案
- # ExerciseStandardAnswer.find_each do |esa|
- # answer_text = ke_transform_to_md esa.answer_text
- # esa.update_column(:answer_text, answer_text)
- # end
- #
- # 试卷题库的问题标题
- # ExerciseBankQuestion.find_each do |ebq|
- # question_title = ke_transform_to_md ebq.question_title
- # ebq.update_column(:question_title, question_title)
- # end
- #
- # # 试卷答案
- # ExerciseBankStandardAnswer.find_each do |ebsa|
- # answer_text = ke_transform_to_md ebsa.answer_text
- # ebsa.update_column(:answer_text, answer_text)
- # end
-
- # # 问卷的标题
- # PollQuestion.find_each do |pq|
- # question_title = ke_transform_to_md pq.question_title
- # pq.update_column(:question_title, question_title)
- # end
-
- end
-end
diff --git a/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb b/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb
deleted file mode 100644
index cd45ec196..000000000
--- a/db/migrate/20190805014624_migrate_anonymous_tiding_type.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class MigrateAnonymousTidingType < ActiveRecord::Migration[5.2]
- def change
- Tiding.where(container_type: "StudentWorksScore", extra: "3").update_all(tiding_type: "System", trigger_user_id: 0)
- Tiding.where(container_type: "StudentWorksScoresAppeal", parent_container_type: "StudentWork", tiding_type: "HomeworkCommon").update_all(tiding_type: "System", trigger_user_id: 0)
- end
-end
diff --git a/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb b/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb
deleted file mode 100644
index 95edeb7d5..000000000
--- a/db/migrate/20190805061306_add_exec_time_to_evaluate_records.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class AddExecTimeToEvaluateRecords < ActiveRecord::Migration[5.2]
- def change
- # remove_columns :evaluate_records, :exec_time if EvaluateRecord.first.attributes.include?("exec_time")
- #
- # add_column :evaluate_records, :exec_time, :integer
- end
-end
diff --git a/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb b/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb
deleted file mode 100644
index c8068e049..000000000
--- a/db/migrate/20190806062209_second_mofidy_ke_contents_for_md.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-class SecondMofidyKeContentsForMd < ActiveRecord::Migration[5.2]
- include ActionView::Helpers::SanitizeHelper
- def change
- # def ke_transform_to_md content
- # return content if content.blank?
- # s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style))
- # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", " ").gsub(/(\n)+/, "
")
- # .gsub("\t", " ").gsub("\n", "").gsub(" ", " ").gsub(/(
)+/, "
")
- #
- # end
- #
- # # 作业
- # HomeworkCommon.find_each do |hc|
- # description = ke_transform_to_md hc.description
- # reference_answer = ke_transform_to_md hc.reference_answer
- # explanation = ke_transform_to_md hc.explanation
- # hc.update_attributes(description: description, reference_answer: reference_answer, explanation: explanation)
- # end
- #
- # # 作业题库
- # HomeworkBank.find_each do |hb|
- # description = ke_transform_to_md hb.description
- # reference_answer = ke_transform_to_md hb.reference_answer
- # hb.update_attributes(description: description, reference_answer: reference_answer)
- # end
- #
- # # 毕业任务
- # GraduationTask.find_each do |gt|
- # description = ke_transform_to_md gt.description
- # gt.update_column(:description, description)
- # end
- #
- # # 毕设选题
- # GraduationTopic.find_each do |gt|
- # description = ke_transform_to_md gt.description
- # gt.update_column(:description, description)
- # end
- #
- # # 毕设作品
- # GraduationWork.find_each do |gw|
- # description = ke_transform_to_md gw.description
- # gw.update_column(:description, description)
- # end
- #
- # # 毕设任务题库
- # GtaskBank.find_each do |gb|
- # description = ke_transform_to_md gb.description
- # gb.update_column(:description, description)
- # end
- #
- # # 毕设选题题库
- # GtopicBank.find_each do |gb|
- # description = ke_transform_to_md gb.description
- # gb.update_column(:description, description)
- # end
- #
- # # 交流问答
- # Memo.find_each do |m|
- # content = ke_transform_to_md m.content
- # m.update_column(:content, content)
- # end
-
- end
-end
diff --git a/db/migrate/20190806063903_third_modify_ke_for_student_work.rb b/db/migrate/20190806063903_third_modify_ke_for_student_work.rb
deleted file mode 100644
index 0b1be8d00..000000000
--- a/db/migrate/20190806063903_third_modify_ke_for_student_work.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class ThirdModifyKeForStudentWork < ActiveRecord::Migration[5.2]
- include ActionView::Helpers::SanitizeHelper
- def change
- # def ke_transform_to_md content
- # return content if content.blank?
- # s_contents = sanitize(content, tags: %w(img a span table td tr tbody pre), attributes: %w(src href target style))
- # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", " ").gsub(/(\n)+/, "
")
- # .gsub("\t", " ").gsub("\n", "").gsub(" ", " ").gsub(/(
)+/, "
")
- # end
- #
- # # 学生的作品 过滤掉一些描述的ke图片的作品
- # StudentWork.where("description is not null and LENGTH(description) < 1000000").find_each do |sw|
- # description = ke_transform_to_md sw.description
- # sw.update_column(:description, description)
- # end
- end
-end
diff --git a/db/migrate/20190808025851_create_videos.rb b/db/migrate/20190808025851_create_videos.rb
deleted file mode 100644
index e7d89f7eb..000000000
--- a/db/migrate/20190808025851_create_videos.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class CreateVideos < ActiveRecord::Migration[5.2]
- def change
- create_table :videos do |t|
- t.references :user, index: true, type: :integer
- t.string :title
- t.string :uuid, comment: 'Aliyun媒体ID'
- t.string :cover_url, comment: '视频封面'
- t.string :file_url, comment: '视频地址'
-
- t.string :status
- t.string :vod_status, comment: 'Aliyun媒体状态'
-
- t.datetime :published_at, index: true
-
- t.timestamps
-
- t.index :uuid, unique: true
- end
- end
-end
diff --git a/db/migrate/20190809010636_create_video_applies.rb b/db/migrate/20190809010636_create_video_applies.rb
deleted file mode 100644
index e8b4037c5..000000000
--- a/db/migrate/20190809010636_create_video_applies.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class CreateVideoApplies < ActiveRecord::Migration[5.2]
- def change
- create_table :video_applies do |t|
- t.references :video, index: true, type: :integer
- t.string :status
- t.string :reason
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20190813015633_add_new_column_to_course.rb b/db/migrate/20190813015633_add_new_column_to_course.rb
deleted file mode 100644
index cfadc4ce4..000000000
--- a/db/migrate/20190813015633_add_new_column_to_course.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class AddNewColumnToCourse < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :start_date, :date
- add_column :courses, :subject_id, :integer, default: 0
-
- add_index :courses, :subject_id
- end
-end
diff --git a/db/migrate/20190813074730_add_excellent_to_courses.rb b/db/migrate/20190813074730_add_excellent_to_courses.rb
deleted file mode 100644
index c83fcc702..000000000
--- a/db/migrate/20190813074730_add_excellent_to_courses.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddExcellentToCourses < ActiveRecord::Migration[5.2]
- def change
- add_column :courses, :excellent, :boolean, default: false
- end
-end
diff --git a/db/migrate/20190815064542_modify_class_period_for_courses.rb b/db/migrate/20190815064542_modify_class_period_for_courses.rb
deleted file mode 100644
index c0f8600b4..000000000
--- a/db/migrate/20190815064542_modify_class_period_for_courses.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class ModifyClassPeriodForCourses < ActiveRecord::Migration[5.2]
- def change
- Course.find_each do |c|
- c.update_column(:class_period, c.class_period.to_i)
- end
- change_column :courses, :class_period, :integer
- end
-end
diff --git a/db/migrate/20190815085136_modify_path_for_challenges.rb b/db/migrate/20190815085136_modify_path_for_challenges.rb
deleted file mode 100644
index a17fdbd04..000000000
--- a/db/migrate/20190815085136_modify_path_for_challenges.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ModifyPathForChallenges < ActiveRecord::Migration[5.2]
- def change
- change_column :challenges, :path, :text
- end
-end
diff --git a/db/migrate/20190819081514_add_filesize_to_videos.rb b/db/migrate/20190819081514_add_filesize_to_videos.rb
deleted file mode 100644
index da5b6fb50..000000000
--- a/db/migrate/20190819081514_add_filesize_to_videos.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class AddFilesizeToVideos < ActiveRecord::Migration[5.2]
- def change
- add_column :videos, :filesize, :integer, default: 0
- end
-end
diff --git a/db/migrate/20190820021047_migrate_course_task_position.rb b/db/migrate/20190820021047_migrate_course_task_position.rb
deleted file mode 100644
index f32ac88b1..000000000
--- a/db/migrate/20190820021047_migrate_course_task_position.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class MigrateCourseTaskPosition < ActiveRecord::Migration[5.2]
- def change
- add_column :homework_commons, :position, :integer, :default => 0
- end
-end
diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb
deleted file mode 100644
index acf99b9e5..000000000
--- a/db/migrate/20190820102040_change_exercise_1930_position.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-class ChangeExercise1930Position < ActiveRecord::Migration[5.2]
- def change
- exs = Exercise.all.includes(:exercise_questions)
- exs.each do |ex|
- ex_questions = ex&.exercise_questions&.select(:id,:question_number,:exercise_id)&.order("question_number ASC") #试卷的位置迁移
- if ex_questions.present?
- ex_questions.each_with_index do |q,index|
- puts index
- q_num = index + 1
- if q.question_number.to_i != q_num
- q.update_attributes(question_number: q_num)
- end
- end
- end
-
- ex_q_bank = ex&.exercise_bank&.exercise_bank_questions&.select(:id,:question_number,:exercise_bank_id,:shixun_id)&.order("question_number ASC") #试卷的习题库位置迁移
- if ex_q_bank.present?
- ex_q_bank.each_with_index do |q,index|
- puts index
- q_num_1 = index + 1
- if q.question_number.to_i != q_num_1
- q.update_attributes(question_number: q_num_1)
- end
- end
- end
- end
-
- end
-end
diff --git a/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb b/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb
deleted file mode 100644
index 9a19b12e3..000000000
--- a/db/migrate/20190821072722_migrate_course_shixun_homework_position.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class MigrateCourseShixunHomeworkPosition < ActiveRecord::Migration[5.2]
- def change
- Course.find_each do |course|
- puts course.id
- course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC,
- homework_commons.created_at DESC").reverse.each_with_index do |homework, index|
- homework.update_columns(position: index + 1)
- end
- end
- end
-end
diff --git a/db/migrate/20190822022306_add_exercise_user_update.rb b/db/migrate/20190822022306_add_exercise_user_update.rb
deleted file mode 100644
index 7a8784c30..000000000
--- a/db/migrate/20190822022306_add_exercise_user_update.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-class AddExerciseUserUpdate < ActiveRecord::Migration[5.2]
-
- # include ExercisesHelper
- # def change
- # #2019,8,22添加
- # two_months = Time.now - 2.months
- # exs = Exercise.all.is_exercise_published.where("publish_time > ?",two_months).includes(:exercise_questions,:exercise_users)
- # exs.each do |ex|
- # if ex.exercise_questions.where("created_at < ?",Time.now - 1.month).pluck(:question_type).include?(1) #含有多选题,且是1个月前创建的才更新
- # ex_users = ex.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months)
- # if ex_users.exists?
- # ex_users.each do |ex_user|
- # calculate_score = calculate_student_score(ex,ex_user.user)[:total_score]
- # subjective_score = ex_user.subjective_score
- # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
- # total_score = calculate_score + total_score_subjective_score
- # ex_user.update_attributes(score:total_score,objective_score:calculate_score)
- # puts ex_user.id
- # end
- # end
- # end
- # end
- #
- # #1936的试卷成绩有问题。
- # # #https://www.educoder.net/courses/2935/exercises/1936/users/pizfnr5ts
- # ex_special = Exercise.find_by_id(1936)
- # ex_special_users = ex_special.exercise_users.exercise_user_committed.where("end_at is not null and end_at > ?",two_months)
- # if ex_special.present? && ex_special_users.exists?
- # ex_special_users.each do |ex_user|
- # calculate_score = calculate_student_score(ex_special,ex_user.user)[:total_score]
- # subjective_score = ex_user.subjective_score
- # total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
- # total_score = calculate_score + total_score_subjective_score
- # ex_user.update_attributes(score:total_score,objective_score:calculate_score)
- # puts ex_user.id
- # end
- # end
- # end
-end
diff --git a/db/migrate/20190823015610_add_message_count_for_boards.rb b/db/migrate/20190823015610_add_message_count_for_boards.rb
deleted file mode 100644
index 6f121cfc0..000000000
--- a/db/migrate/20190823015610_add_message_count_for_boards.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class AddMessageCountForBoards < ActiveRecord::Migration[5.2]
- def change
- boards = Board.where(:parent_id => 0)
- Board.reset_column_information
- boards.find_each do |board|
- Board.reset_counters board.id, :messages
- end
- end
-end
diff --git a/db/migrate/20190823024643_modify_course_introduction_for_boards.rb b/db/migrate/20190823024643_modify_course_introduction_for_boards.rb
deleted file mode 100644
index 3dfcf09f8..000000000
--- a/db/migrate/20190823024643_modify_course_introduction_for_boards.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-class ModifyCourseIntroductionForBoards < ActiveRecord::Migration[5.2]
- def change
- platform = PlatformSample.where(:samples_type => "courseGuide").first
- content = '大家好!
-
-欢迎进入在线课堂!
-
-该课堂对应于一个或多个线下班级,课堂成员可以利用老师发布的邀请码申请加入。
-
-在这里,老师和教辅将结合教学内容,把不同类型的实训项目发布给大家,让大家在真实的实战环境中得到锻炼。
-
-那么什么是实训项目呢?大家有空自己尝试一下就知道了:
-
-- Python实训:[Python程序设计入门](https://www.educoder.net/paths/13) | [大学计算机基础——基于Python](https://www.educoder.net/paths/11)
-
-- Java实训:[Java语言程序设计(基础篇)](https://www.educoder.net/paths/38)
-
-- C/C++实训:[C/C++程序设计](https://www.educoder.net/paths/3) | [数据结构与算法(C语言)](https://www.educoder.net/paths/4)
-
-- Matlab实训:[智取MATLAB:基本语法](https://www.educoder.net/shixuns/7bvs54gw/challenges) | [控制结构](https://www.educoder.net/shixuns/q4fowkfa/challenges) | [矩阵进阶](https://www.educoder.net/shixuns/grunzcs3/challenges)
-
-- HTML/CSS实训:[HTML5+CSS3网页制作(基础篇)](https://www.educoder.net/paths/15)
-
-- 云计算实训:[Docker企业级实训(基础篇)](https://www.educoder.net/paths/29)
-
-... ... 等等
-
-你们现在就可以去体验哦!
-
-欢迎提出宝贵建议,平台一定会给您带来更多惊喜!
-
-
-支持团队'
- platform.update_column(:contents, content)
- messages = Message.where(subject: "新课导语")
- messages.find_each do |m|
- m.update_column(:is_md, true)
- message_detail = m.message_detail
- message_detail.update_column(:content, content) if message_detail
- end
- end
-end
diff --git a/db/migrate/20190823063747_modify_contents_for_old_message_details.rb b/db/migrate/20190823063747_modify_contents_for_old_message_details.rb
deleted file mode 100644
index 4607881fe..000000000
--- a/db/migrate/20190823063747_modify_contents_for_old_message_details.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class ModifyContentsForOldMessageDetails < ActiveRecord::Migration[5.2]
- def change
- messages = Message.where(subject: "新课导语").where.not(parent_id: 0).where("created_on < '2019-08-23 02:00:00'")
- messages.find_each do |m|
- m.update_column(:is_md, true)
- message_detail = m.message_detail
- if message_detail
- content = OldMessageDetail.find_by_id(message_detail.id)&.content
- message_detail.update_column(:content, content)
- end
- end
- end
-end
diff --git a/db/migrate/20190823090957_rechange_exercise_1936_scores.rb b/db/migrate/20190823090957_rechange_exercise_1936_scores.rb
deleted file mode 100644
index f089714ee..000000000
--- a/db/migrate/20190823090957_rechange_exercise_1936_scores.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class RechangeExercise1936Scores < ActiveRecord::Migration[5.2]
- include ExercisesHelper
- def change
- #1936的试卷成绩有问题。
- # #https://www.educoder.net/courses/2935/exercises/1936/users/pizfnr5ts
- ex_special = Exercise.find_by_id(1936)
- ex_special_users = ex_special&.exercise_users&.exercise_user_committed&.where("end_at is not null and end_at > ?",Time.now - 2.months)
- if ex_special.present? && ex_special_users.exists?
- ex_special_users.each do |ex_user|
- calculate_score = calculate_student_score(ex_special,ex_user.user)[:total_score]
- subjective_score = ex_user.subjective_score
- total_score_subjective_score = subjective_score < 0.0 ? 0.0 : subjective_score
- total_score = calculate_score + total_score_subjective_score
- ex_user.update_attributes(score:total_score,objective_score:calculate_score)
- puts ex_user.id
- end
- end
- end
-end
diff --git a/db/migrate/20190824032658_migrate_subject_shixun_count.rb b/db/migrate/20190824032658_migrate_subject_shixun_count.rb
deleted file mode 100644
index bef29346e..000000000
--- a/db/migrate/20190824032658_migrate_subject_shixun_count.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class MigrateSubjectShixunCount < ActiveRecord::Migration[5.2]
- def change
- Subject.reset_column_information
- Subject.all.each do |subject|
- Subject.reset_counters subject.id, :stage_shixuns
- Subject.reset_counters subject.id, :shixuns
- end
- end
-end
diff --git a/db/migrate/20190827055814_modify_challnege_score_for_choose.rb b/db/migrate/20190827055814_modify_challnege_score_for_choose.rb
deleted file mode 100644
index 7b96877e3..000000000
--- a/db/migrate/20190827055814_modify_challnege_score_for_choose.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class ModifyChallnegeScoreForChoose < ActiveRecord::Migration[5.2]
- def change
- challenges = Challenge.where(st: 1)
- challenges.find_each do |c|
- puts(c.id)
- score = c.challenge_chooses.sum(:score)
- c.update_column(:score, score)
- end
- end
-end
diff --git a/db/seeds.rb b/db/seeds.rb
index d3168c926..a7ae6e804 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -9,6 +9,7 @@
# 创建匿名用户
user_params = [
{
+ id: 1,
login: 'educoder',
hashed_password: '0434e43e945cd5aa375dc268f6af77a1c881852a',
lastname: '社区导师',
@@ -18,7 +19,19 @@ user_params = [
language: 'zh',
show_realname: '社区导师',
professional_certification: 1,
- certification: 1
+ certification: 1,
+ salt: '7af297891a2a81231445b0dfb1b2eaa6',
+ profile_completed: 1
+ },
+ {
+ id: 2,
+ hashed_password: 'aaacd2fdabaaa3a54c4ada625a2611b5f0ffa437',
+ status: 3,
+ type: 'AnonymousUser',
+ salt: '96a9104963f8f2f9d35f1f384f8e8bf7'
}
]
-users = User.create
+users = User.create!(user_params)
+users.each do |user|
+ UserExtension.create!(user_id: user.id, gender: 0)
+end