Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
ca659822
Commit
ca659822
authored
Feb 14, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Gitlab::Database.with_connection_pool from !9192
parent
ae93d08b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
41 deletions
+24
-41
db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
.../20170206040400_remove_inactive_default_email_services.rb
+23
-40
db/schema.rb
db/schema.rb
+1
-1
No files found.
db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
View file @
ca659822
...
...
@@ -6,53 +6,36 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
disable_ddl_transaction!
def
up
pool
=
create_connection_pool
threads
=
[]
threads
<<
Thread
.
new
do
pool
.
with_connection
do
|
connection
|
connection
.
execute
<<-
SQL
.
strip_heredoc
DELETE FROM services
WHERE type = 'BuildsEmailService'
AND active IS FALSE
AND properties = '{"notify_only_broken_builds":true}';
SQL
Gitlab
::
Database
.
with_connection_pool
(
2
)
do
|
pool
|
threads
=
[]
threads
<<
Thread
.
new
do
pool
.
with_connection
do
|
connection
|
connection
.
execute
<<-
SQL
.
strip_heredoc
DELETE FROM services
WHERE type = 'BuildsEmailService'
AND active IS FALSE
AND properties = '{"notify_only_broken_builds":true}';
SQL
end
end
end
threads
<<
Thread
.
new
do
pool
.
with_connection
do
|
connection
|
connection
.
execute
<<-
SQL
.
strip_heredoc
DELETE FROM services
WHERE type = 'PipelinesEmailService'
AND active IS FALSE
AND properties = '{"notify_only_broken_pipelines":true}';
SQL
threads
<<
Thread
.
new
do
pool
.
with_connection
do
|
connection
|
connection
.
execute
<<-
SQL
.
strip_heredoc
DELETE FROM services
WHERE type = 'PipelinesEmailService'
AND active IS FALSE
AND properties = '{"notify_only_broken_pipelines":true}';
SQL
end
end
end
threads
.
each
(
&
:join
)
pool
.
disconnect!
threads
.
each
(
&
:join
)
end
end
def
down
# Nothing can be done to restore the records
end
private
def
create_connection_pool
# See activerecord-4.2.7.1/lib/active_record/connection_adapters/connection_specification.rb
env
=
Rails
.
env
original_config
=
ActiveRecord
::
Base
.
configurations
env_config
=
original_config
[
env
].
merge
(
'pool'
=>
2
)
config
=
original_config
.
merge
(
env
=>
env_config
)
spec
=
ActiveRecord
::
ConnectionAdapters
::
ConnectionSpecification
::
Resolver
.
new
(
config
).
spec
(
env
.
to_sym
)
ActiveRecord
::
ConnectionAdapters
::
ConnectionPool
.
new
(
spec
)
end
end
db/schema.rb
View file @
ca659822
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201702
04181513
)
do
ActiveRecord
::
Schema
.
define
(
version:
201702
10075922
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment