Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
This repository was archived by the owner on Sep 25, 2019. It is now read-only.

V1 database records fixes #22

@allenwq

Description

@allenwq

Because of the lacking of foreign_key constraint, some of the records are not valid but still stores in db, to fix:

  • Add null: false to question_assessments, question_id and assessment_id, there are question_assessments with nil assessment_id
  • Handle question_assessments with deleted_assessments
  • Tag and Tag group id inconsistent, probably can be fixed by:
Tag set course_id same as tag_group course_id
# Tag.where(course_id: nil).each { |t| id = t.tag_group.course_id; t.update_column(:course_id, id)}
  • Tag and Taggable in different courses. Should drop the taggable instead.

  • Drop answers with null submission and question, add null: false

  • inconsistent folders (folders and subfolder belong to differernt course)

def fix_course_id(folder, course_id)
  return if folder.nil?

  if folder.course_id != course_id
    puts "Update folder #{folder.name} #{folder.id} to course #{course_id}, origin: #{folder.course_id}"
    folder.update_column(:course_id, course_id)
  end

  folder.subfolders.each { |f| fix_course_id(f, course_id) }
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions