class MigrateShixunStatus < ActiveRecord::Migration[5.2]
  def change
    # 平台上所有已发布且未隐藏的实训都设为公开
    Shixun.unhidden.update_all(public: 2)

    # 所有已申请发布的实训状态都改为已发布，申请发布改为申请公开
    Shixun.where(status: 1, id: ApplyAction.where(container_type: 'ApplyShixun', status: 0).pluck(:container_id)).update_all(status: 2, public: 1)
  end
end
