Commit 887aeefb authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use IS FALSE for both pg and mysql; Handle connections

by ourselves so that even if the setting has 1 connection
we could still use more connections.
parent 25cd5aa2
...@@ -7,14 +7,14 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration ...@@ -7,14 +7,14 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
builds_service = spawn <<-SQL.strip_heredoc builds_service = spawn <<-SQL.strip_heredoc
DELETE FROM services DELETE FROM services
WHERE type = 'BuildsEmailService' WHERE type = 'BuildsEmailService'
AND active = #{false_value} AND active IS FALSE
AND properties = '{"notify_only_broken_builds":true}'; AND properties = '{"notify_only_broken_builds":true}';
SQL SQL
pipelines_service = spawn <<-SQL.strip_heredoc pipelines_service = spawn <<-SQL.strip_heredoc
DELETE FROM services DELETE FROM services
WHERE type = 'PipelinesEmailService' WHERE type = 'PipelinesEmailService'
AND active = #{false_value} AND active IS FALSE
AND properties = '{"notify_only_broken_pipelines":true}'; AND properties = '{"notify_only_broken_pipelines":true}';
SQL SQL
...@@ -25,17 +25,19 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration ...@@ -25,17 +25,19 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
def spawn(query) def spawn(query)
Thread.new do Thread.new do
ActiveRecord::Base.connection_pool.with_connection do with_connection do |connection|
ActiveRecord::Base.connection.execute(query) connection.execute(query)
end end
end end
end end
def quote(value) def with_connection
ActiveRecord::Base.connection.quote(value) pool = ActiveRecord::Base.establish_connection
end connection = pool.connection
yield(connection)
def false_value ensure
quote(false) connection.close
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment