From 131be5a31b77d02cc1aac1bb3278b0c8f8f3bea5 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 17 Mar 2014 18:14:44 -0700 Subject: [PATCH] fixes #1535 --- script/fixes/028_fix_has_children.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 script/fixes/028_fix_has_children.rb diff --git a/script/fixes/028_fix_has_children.rb b/script/fixes/028_fix_has_children.rb new file mode 100644 index 000000000..7798da0ed --- /dev/null +++ b/script/fixes/028_fix_has_children.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) + +ActiveRecord::Base.connection.execute("set statement_timeout = 0") + +CurrentUser.user = User.admins.first +CurrentUser.ip_addr = "127.0.0.1" + +CurrentUser.without_safe_mode do + Post.update_all("has_children = false", "has_children = true") + Post.update_all("has_children = true", "exists (select 1 from posts _ where _.parent_id = posts.id limit 1)") +end