class MigrateCourseTags < ActiveRecord::Migration
  def self.up
    # 原课程的标签数据迁移成新模式
    taggings = ActsAsTaggableOn::Tagging.find_all_by_taggable_type('Project')
    taggings.each do |tagging|
      project = Project.find_by_id(tagging.taggable_id)
      if project && project.project_type == 1
        tagging.taggable_type= 'Course'
        tagging.taggable_id = project.course_extra.id
        tagging.save(:validate => false)
      end
    end
  end

  def self.down
  end
end
