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: 7a4987e63e2554b3570cdc243b569b292ff6d9d7c0821ebeeb78768e244e8c93
4
- data.tar.gz: fccba58bc0876d615dfbe62b4a14486dac3bf67eefd2614da23363ea52f7519b
3
+ metadata.gz: faa823b7357f66f7de85bb3ab50b6df99beb0c2505bcbbeafac9cc1aa4581d7e
4
+ data.tar.gz: 688c6ed703809a88ee86134d43021730495bcaaa8ca2132c81a0926edc2d1eca
5
5
  SHA512:
6
- metadata.gz: 9344f045cce08fad0308aa7767d3581e527fd2afd6897c9ae50461070e9e730c4a392ab9a9c47218cf5cc36f2d26afd0aadebea922bbd5f3c0724ada3a50c182
7
- data.tar.gz: fc6f5e72ccb01955d028796c53d389a472d3157f05a1350a5c9c200714a48cc67ceb57f1def6d6e8be0fb5187ffb676cef855ea428f3c3042b6165a3ff72a2a5
6
+ metadata.gz: 8e9babc77b5dffe78007005f7abec607a9e5597aafa3676082c501da68c9cce9748714db5068bdc6b7573edef1ed8ad608893820c5396fbc450fa59b5c34f9f2
7
+ data.tar.gz: 72dcbaa612143fe7a3235f23982b83b4fddb86a7c39814dec128d7fc6f4a141b368de82392e2f515424055b148d11181fc3fd27e608f174879735c30d1d13ce4
@@ -191,7 +191,7 @@ module ActiveRecordShards
191
191
  end
192
192
 
193
193
  def shard_env
194
- ActiveRecordShards.rails_env
194
+ ActiveRecordShards.app_env
195
195
  end
196
196
 
197
197
  # Make these few schema related methods available before having switched to
@@ -26,11 +26,11 @@ module ActiveRecordShards
26
26
  the_shard = shard(klass)
27
27
 
28
28
  @shard_names ||= {}
29
- @shard_names[ActiveRecordShards.rails_env] ||= {}
30
- @shard_names[ActiveRecordShards.rails_env][the_shard] ||= {}
31
- @shard_names[ActiveRecordShards.rails_env][the_shard][try_replica] ||= {}
32
- @shard_names[ActiveRecordShards.rails_env][the_shard][try_replica][@on_replica] ||= begin
33
- s = ActiveRecordShards.rails_env.dup
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.rails_env
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.rails_env) || key.end_with?("_replica", "_slave")
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.rails_env) || key.end_with?("_replica", "_slave")
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.rails_env.to_sym)
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"
@@ -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.rails_env
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.19.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-03-04 00:00:00.000000000 Z
16
+ date: 2022-04-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord