From 98e58ed58911103e396afde9bc49e15ba0e9cc22 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 17 Jan 2020 18:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...117095750_modify_1_wechat_support_for_shixuns.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb diff --git a/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb new file mode 100644 index 000000000..3e099e9ac --- /dev/null +++ b/db/migrate/20200117095750_modify_1_wechat_support_for_shixuns.rb @@ -0,0 +1,13 @@ +class Modify1WechatSupportForShixuns < ActiveRecord::Migration[5.2] + def change + shixuns = Shixun.joins(:challenges).where(is_wechat_support: true) + .select("shixuns.*, challenges.path path") + shixuns.each do |shixun| + if shixun.path.split(";").count > 1 + shixun.update_attribute(:is_wechat_support, false) + end + end + Shixun.joins(:challenges).where(challenges: {st: 1}).update_all(is_wechat_support: false) + + end +end