active_record_shards 3.11.2 → 3.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_record_shards.rb +1 -1
- data/lib/active_record_shards/association_collection_connection_selection.rb +0 -2
- data/lib/active_record_shards/configuration_parser.rb +5 -0
- data/lib/active_record_shards/connection_switcher-4-0.rb +1 -4
- data/lib/active_record_shards/connection_switcher-5-0.rb +1 -1
- data/lib/active_record_shards/connection_switcher-5-1.rb +1 -1
- data/lib/active_record_shards/connection_switcher.rb +8 -2
- data/lib/active_record_shards/migration.rb +0 -21
- data/lib/active_record_shards/model.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09b0da024cd5b13020b14dde7e822530b7f82fcc'
|
4
|
+
data.tar.gz: 0c2d9149aa653176d122c97fe632e6d47e00716a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ec6f7c8e6c8639beee8aea8ded4c0b8aa910b839c4f0350836077bc745692330a0106df273b7b78e46251c0b3a4fb0a27e6164a17475669eac8afea0444d5c
|
7
|
+
data.tar.gz: dd24e476ad1c062427b54e5898f5a33393547acfeb1d1faf63024b4b900c2144672d2c67c2c42023225ef63b0e0c69c3722c188f320f6d50fc28e0773f356e21
|
data/lib/active_record_shards.rb
CHANGED
@@ -30,7 +30,7 @@ when '3.2'
|
|
30
30
|
require 'active_record_shards/patches-3-2'
|
31
31
|
when '4.2'
|
32
32
|
require 'active_record_shards/patches-4-2'
|
33
|
-
when '5.0', '5.1'
|
33
|
+
when '5.0', '5.1', '5.2'
|
34
34
|
require 'active_record_shards/patches-5-0'
|
35
35
|
else
|
36
36
|
raise "ActiveRecordShards is not compatible with #{ActiveRecord::VERSION::STRING}"
|
@@ -32,8 +32,6 @@ module ActiveRecordShards
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissing
|
35
|
-
# would love to not rely on version here, unfortunately @association_collection
|
36
|
-
# is a sensitive little bitch of an object.
|
37
35
|
reflection = @association_collection.proxy_association.reflection
|
38
36
|
reflection.klass.on_cx_switch_block(@which) { @association_collection.send(method, *args, &block) }
|
39
37
|
end
|
@@ -10,6 +10,11 @@ module ActiveRecordShards
|
|
10
10
|
|
11
11
|
conf.to_a.each do |env_name, env_config|
|
12
12
|
next unless shards = env_config.delete('shards')
|
13
|
+
|
14
|
+
unless shards.keys.all? { |shard_name| shard_name.is_a?(Integer) }
|
15
|
+
raise "All shard names must be integers: #{shards.keys.inspect}."
|
16
|
+
end
|
17
|
+
|
13
18
|
env_config['shard_names'] = shards.keys
|
14
19
|
shards.each do |shard_name, shard_conf|
|
15
20
|
expand_child!(env_config, shard_conf)
|
@@ -22,14 +22,11 @@ module ActiveRecordShards
|
|
22
22
|
spec = configurations[name]
|
23
23
|
|
24
24
|
if spec.nil?
|
25
|
-
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in database.
|
25
|
+
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in your database config. (configurations: #{configurations.inspect})"
|
26
26
|
end
|
27
27
|
|
28
28
|
# in 3.2 rails is asking for a connection pool in a map of these ConnectionSpecifications. If we want to re-use connections,
|
29
29
|
# we need to re-use specs.
|
30
|
-
|
31
|
-
# note that since we're subverting the standard establish_connection path, we have to handle the funky autoloading of the
|
32
|
-
# connection adapter ourselves.
|
33
30
|
if ActiveRecord::VERSION::MAJOR >= 4
|
34
31
|
specification_cache[name] ||= begin
|
35
32
|
resolver = ActiveRecordShards::ConnectionSpecification::Resolver.new configurations
|
@@ -4,7 +4,7 @@ module ActiveRecordShards
|
|
4
4
|
name = current_shard_selection.resolve_connection_name(sharded: is_sharded?, configurations: configurations)
|
5
5
|
|
6
6
|
unless configurations[name] || name == "primary"
|
7
|
-
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in database.
|
7
|
+
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in your database config. (configurations: #{configurations.inspect})"
|
8
8
|
end
|
9
9
|
|
10
10
|
name
|
@@ -4,7 +4,7 @@ module ActiveRecordShards
|
|
4
4
|
name = current_shard_selection.resolve_connection_name(sharded: is_sharded?, configurations: configurations)
|
5
5
|
|
6
6
|
unless configurations[name] || name == "primary"
|
7
|
-
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in database.
|
7
|
+
raise ActiveRecord::AdapterNotSpecified, "No database defined by #{name} in your database config. (configurations: #{configurations.inspect})"
|
8
8
|
end
|
9
9
|
|
10
10
|
name
|
@@ -139,7 +139,10 @@ module ActiveRecordShards
|
|
139
139
|
|
140
140
|
def shard_names
|
141
141
|
unless config = configurations[shard_env]
|
142
|
-
raise "Did not find #{shard_env} in configurations, did you forget to add it to your database
|
142
|
+
raise "Did not find #{shard_env} in configurations, did you forget to add it to your database config? (configurations: #{configurations.inspect})"
|
143
|
+
end
|
144
|
+
unless config.fetch(SHARD_NAMES_CONFIG_KEY, []).all? { |shard_name| shard_name.is_a?(Integer) }
|
145
|
+
raise "All shard names must be integers: #{config[SHARD_NAMES_CONFIG_KEY].inspect}."
|
143
146
|
end
|
144
147
|
config[SHARD_NAMES_CONFIG_KEY] || []
|
145
148
|
end
|
@@ -153,6 +156,9 @@ module ActiveRecordShards
|
|
153
156
|
end
|
154
157
|
|
155
158
|
if options.key?(:shard)
|
159
|
+
unless configurations[shard_env]
|
160
|
+
raise "Did not find #{shard_env} in configurations, did you forget to add it to your database config? (configurations: #{configurations.inspect})"
|
161
|
+
end
|
156
162
|
current_shard_selection.shard = options[:shard]
|
157
163
|
end
|
158
164
|
|
@@ -214,7 +220,7 @@ when '3.2', '4.2'
|
|
214
220
|
require 'active_record_shards/connection_switcher-4-0'
|
215
221
|
when '5.0'
|
216
222
|
require 'active_record_shards/connection_switcher-5-0'
|
217
|
-
when '5.1'
|
223
|
+
when '5.1', '5.2'
|
218
224
|
require 'active_record_shards/connection_switcher-5-1'
|
219
225
|
else
|
220
226
|
raise "ActiveRecordShards is not compatible with #{ActiveRecord::VERSION::STRING}"
|
@@ -14,24 +14,6 @@ module ActiveRecord
|
|
14
14
|
alias_method :"#{m}_without_sharding", m.to_sym
|
15
15
|
alias_method m.to_sym, :"#{m}_with_sharding"
|
16
16
|
end
|
17
|
-
|
18
|
-
def bootstrap_migrations_from_nil_shard(migrations_path, this_migration = nil)
|
19
|
-
migrations = nil
|
20
|
-
ActiveRecord::Base.on_shard(nil) do
|
21
|
-
migrations = ActiveRecord::Migrator.new(:up, migrations_path).migrated
|
22
|
-
end
|
23
|
-
|
24
|
-
puts "inserting #{migrations.size} migrations on all shards..."
|
25
|
-
ActiveRecord::Base.on_all_shards do
|
26
|
-
migrator = ActiveRecord::Migrator.new(:up, migrations_path)
|
27
|
-
migrations.each do |m|
|
28
|
-
migrator.__send__(:record_version_state_after_migrating, m)
|
29
|
-
end
|
30
|
-
if this_migration
|
31
|
-
migrator.__send__(:record_version_state_after_migrating, this_migration)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
17
|
end
|
36
18
|
|
37
19
|
# don't allow Migrator class to cache versions
|
@@ -82,9 +64,6 @@ module ActiveRecordShards
|
|
82
64
|
end
|
83
65
|
end
|
84
66
|
|
85
|
-
# ok, so some 'splaining to do. Rails 3.1 puts the migrate() method on the instance of the
|
86
|
-
# migration, where it should have been. But this makes our monkey patch incompatible.
|
87
|
-
# So we're forced to *either* include or extend this.
|
88
67
|
module ActualMigrationExtension
|
89
68
|
def migrate_with_forced_shard(direction)
|
90
69
|
if migration_shard.blank?
|
@@ -9,7 +9,7 @@ module ActiveRecordShards
|
|
9
9
|
self.sharded = false
|
10
10
|
end
|
11
11
|
|
12
|
-
def is_sharded? # rubocop:disable
|
12
|
+
def is_sharded? # rubocop:disable Naming/PredicateName
|
13
13
|
if self == ActiveRecord::Base
|
14
14
|
sharded != false && supports_sharding?
|
15
15
|
elsif self == base_class
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_shards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.11.
|
4
|
+
version: 3.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.50.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.50.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: minitest
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.6.
|
232
|
+
rubygems_version: 2.6.14
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: Simple database switching for ActiveRecord.
|