active_record_shards 3.19.3 → 3.20.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa823b7357f66f7de85bb3ab50b6df99beb0c2505bcbbeafac9cc1aa4581d7e
|
4
|
+
data.tar.gz: 688c6ed703809a88ee86134d43021730495bcaaa8ca2132c81a0926edc2d1eca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9babc77b5dffe78007005f7abec607a9e5597aafa3676082c501da68c9cce9748714db5068bdc6b7573edef1ed8ad608893820c5396fbc450fa59b5c34f9f2
|
7
|
+
data.tar.gz: 72dcbaa612143fe7a3235f23982b83b4fddb86a7c39814dec128d7fc6f4a141b368de82392e2f515424055b148d11181fc3fd27e608f174879735c30d1d13ce4
|
@@ -26,11 +26,11 @@ module ActiveRecordShards
|
|
26
26
|
the_shard = shard(klass)
|
27
27
|
|
28
28
|
@shard_names ||= {}
|
29
|
-
@shard_names[ActiveRecordShards.
|
30
|
-
@shard_names[ActiveRecordShards.
|
31
|
-
@shard_names[ActiveRecordShards.
|
32
|
-
@shard_names[ActiveRecordShards.
|
33
|
-
s = ActiveRecordShards.
|
29
|
+
@shard_names[ActiveRecordShards.app_env] ||= {}
|
30
|
+
@shard_names[ActiveRecordShards.app_env][the_shard] ||= {}
|
31
|
+
@shard_names[ActiveRecordShards.app_env][the_shard][try_replica] ||= {}
|
32
|
+
@shard_names[ActiveRecordShards.app_env][the_shard][try_replica][@on_replica] ||= begin
|
33
|
+
s = ActiveRecordShards.app_env.dup
|
34
34
|
s << "_shard_#{the_shard}" if the_shard
|
35
35
|
s << "_replica" if @on_replica && try_replica
|
36
36
|
s
|
@@ -50,7 +50,7 @@ module ActiveRecordShards
|
|
50
50
|
PRIMARY = "primary"
|
51
51
|
def resolve_connection_name(sharded:, configurations:)
|
52
52
|
resolved_shard = sharded ? shard : nil
|
53
|
-
env = ActiveRecordShards.
|
53
|
+
env = ActiveRecordShards.app_env
|
54
54
|
|
55
55
|
@connection_names ||= {}
|
56
56
|
@connection_names[env] ||= {}
|
@@ -10,7 +10,7 @@ namespace :db do
|
|
10
10
|
desc 'Drops the database for the current RAILS_ENV including shards'
|
11
11
|
task drop: :load_config do
|
12
12
|
ActiveRecord::Base.configurations.to_h.each do |key, conf|
|
13
|
-
next if !key.start_with?(ActiveRecordShards.
|
13
|
+
next if !key.start_with?(ActiveRecordShards.app_env) || key.end_with?("_replica", "_slave")
|
14
14
|
|
15
15
|
begin
|
16
16
|
ActiveRecordShards::Tasks.root_connection(conf).drop_database(conf['database'])
|
@@ -31,7 +31,7 @@ namespace :db do
|
|
31
31
|
desc "Create the database defined in config/database.yml for the current RAILS_ENV including shards"
|
32
32
|
task create: :load_config do
|
33
33
|
ActiveRecord::Base.configurations.to_h.each do |key, conf|
|
34
|
-
next if !key.start_with?(ActiveRecordShards.
|
34
|
+
next if !key.start_with?(ActiveRecordShards.app_env) || key.end_with?("_replica", "_slave")
|
35
35
|
|
36
36
|
begin
|
37
37
|
# MysqlAdapter takes charset instead of encoding in Rails 4.2 or greater
|
@@ -48,7 +48,7 @@ namespace :db do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
ActiveRecord::Base.establish_connection(ActiveRecordShards.
|
51
|
+
ActiveRecord::Base.establish_connection(ActiveRecordShards.app_env.to_sym)
|
52
52
|
end
|
53
53
|
|
54
54
|
desc "Raises an error if there are pending migrations"
|
data/lib/active_record_shards.rb
CHANGED
@@ -12,10 +12,12 @@ require 'active_record_shards/default_replica_patches'
|
|
12
12
|
require 'active_record_shards/schema_dumper_extension'
|
13
13
|
|
14
14
|
module ActiveRecordShards
|
15
|
-
def self.
|
15
|
+
def self.app_env
|
16
16
|
env = Rails.env if defined?(Rails.env)
|
17
17
|
env ||= RAILS_ENV if Object.const_defined?(:RAILS_ENV)
|
18
18
|
env ||= ENV['RAILS_ENV']
|
19
|
+
env ||= APP_ENV if Object.const_defined?(:APP_ENV)
|
20
|
+
env ||= ENV['APP_ENV']
|
19
21
|
env || 'development'
|
20
22
|
end
|
21
23
|
end
|
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.
|
4
|
+
version: 3.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Quorning
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2022-
|
16
|
+
date: 2022-04-23 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activerecord
|