/
database.yml
102 lines (93 loc) · 3.38 KB
/
database.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<% mysql = URI(ENV['MYSQL_URL'] || 'mysql://root@127.0.0.1:3306') %>
<% adapter = ActiveRecordHostPool.loaded_db_adapter %>
# ARHP creates separate connection pools based on the pool key.
# The pool key is defined as:
# host / port / socket / username / replica
#
# Therefore two databases with identical host, port, socket, username, and replica status will share a connection pool.
# If any part (host, port, etc.) of the pool key differ, two databases will _not_ share a connection pool.
#
# Below, "test_pool_1..." and "test_pool_2..." have identical host, username, socket, and replica status but the port information differs.
# Here the yml configurations are reformatted as a table to give a visual example:
#
# |----------+----------------+----------------|
# | | test_pool_1 | test_pool_2 |
# |----------+----------------+----------------+
# | host | 127.0.0.1 | 127.0.0.1 |
# | port | | 3306 |
# | socket | | |
# | username | root | root |
# | replica | false | false |
# |----------+----------------+----------------|
#
# Note: The configuration items must be explicitly defined or will be blank in the pool key.
# Configurations with matching _implicit_ items but differing _explicit_ items will create separate pools.
# e.g. "test_pool_1" will default to port 3306 but because it is not explicitly defined it will not share a pool with test_pool_2
#
# ARHP will therefore create the following pool keys:
# test_pool_1 => 127.0.0.1///root/false
# test_pool_2 => 127.0.0.1/3306//root/false
test_pool_1_db_a:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_a
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
# Mimic configurations as read by active_record_shards/ar_flexmaster
test_pool_1_db_a_replica:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_a_replica
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
slave: true
test_pool_1_db_b:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_b
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
test_pool_1_db_not_there:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_not_there
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
test_pool_2_db_d:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_d
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
port: <%= mysql.port %>
test_pool_2_db_e:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_e
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>
port: <%= mysql.port %>
test_pool_3_db_e:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_e
username: john-doe
password:
host: <%= mysql.host %>
port: <%= mysql.port %>
# test_pool_1_db_c needs to be the last database defined in the file
# otherwise the test_models_with_matching_hosts_and_non_matching_databases_issue_exists_without_arhp_patch
# test fails
test_pool_1_db_c:
adapter: <%= adapter %>
encoding: utf8
database: arhp_test_db_c
username: <%= mysql.user %>
password: "<%= mysql.password %>"
host: <%= mysql.host %>