phenix 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/phenix/version.rb +1 -1
  3. data/lib/phenix.rb +21 -10
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47a229b6de3443a5e8f572382ab1bb8600a4f1e9383c37f0283fffcd57a087bf
4
- data.tar.gz: 4251712df756ee74b9caae72353c9f7e0b6aa0a92690b3efa700c9037692d037
3
+ metadata.gz: ae74806ff8278a94e7129e262c977eb9f8a4fe1bdf15f4010aa5c783c726611e
4
+ data.tar.gz: 257a4f7ad4dc019f64722bed3126147804420e831c9ab4f917027efe9cadf828
5
5
  SHA512:
6
- metadata.gz: 8b51d7893f9e264814a39c2228d6ac6a4eff7add76727c1d29e61240996dc909bca0de5fdf790b46e31246acb9a90614e024c8625fa7b16cf0f6331c6ea99a3c
7
- data.tar.gz: af507ea35341614a845082df406d3b040c9fb1b5ca31f5d510677b3194855c4d4bb5f61403dad35c1d68bfbe72c0e10312a20fcf11af5da98ebb9241aedc1887
6
+ metadata.gz: 4b399a58479278268d4135cb1014f798e521ed061a50f22995c6a267a04967805bb6a24bd291bc0d50c0c3288b9ca5002959655f487a6615f21beb0d074c1f99
7
+ data.tar.gz: eb46bf6ddc58543692f264f644a165669066056c5c703b5761a748fe33fd5961c0fdc3a20a187613f5a9db8a36c3c8fb97eebb4bc14fb3e548127c6a2a47da99
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Phenix
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
data/lib/phenix.rb CHANGED
@@ -36,15 +36,25 @@ module Phenix
36
36
  def load_database_config(config_path = Phenix.database_config_path)
37
37
  erb_config = IO.read(config_path)
38
38
  yaml_config = ERB.new(erb_config).result
39
- ActiveRecord::Base.configurations = Phenix.current_configuration = YAML.load(yaml_config)
39
+ begin
40
+ ActiveRecord::Base.configurations = Phenix.current_configuration = YAML.load(yaml_config, aliases: true)
41
+ rescue ArgumentError
42
+ ActiveRecord::Base.configurations = Phenix.current_configuration = YAML.load(yaml_config)
43
+ end
40
44
  end
41
45
 
42
46
  private
43
47
 
44
48
  def create_databases(with_schema)
49
+ # Ensure we've created _every_ database before attempting to populte them
50
+ # This avoids ActiveRecord caching issues if the cache maintains references
51
+ # to stale databases
45
52
  for_each_database do |name, conf|
46
53
  run_mysql_command(conf, "CREATE DATABASE IF NOT EXISTS #{conf['database']}")
47
- ActiveRecord::Base.establish_connection(name.to_sym)
54
+ end
55
+
56
+ for_each_database do |name, conf|
57
+ ActiveRecord::Base.establish_connection(conf)
48
58
  populate_database if with_schema
49
59
  end
50
60
  end
@@ -64,7 +74,15 @@ module Phenix
64
74
  end
65
75
 
66
76
  def for_each_database
67
- configuration_hashes = if ActiveRecord::VERSION::STRING < '6.1'
77
+ parse_configuration_hashes.each do |name, conf|
78
+ next if conf['database'].nil?
79
+ next if Phenix.skip_database.call(name, conf)
80
+ yield(name, conf)
81
+ end
82
+ end
83
+
84
+ def parse_configuration_hashes
85
+ if ActiveRecord::VERSION::STRING < '6.1'
68
86
  ActiveRecord::Base.configurations.to_h
69
87
  else
70
88
  # We need to get all the configurations and put them back into a hash
@@ -72,13 +90,6 @@ module Phenix
72
90
  ActiveRecord::Base.configurations
73
91
  .configurations
74
92
  .map { |c| [c.env_name, c.configuration_hash.with_indifferent_access] }
75
- .to_h
76
- end
77
-
78
- configuration_hashes.each do |name, conf|
79
- next if conf['database'].nil?
80
- next if Phenix.skip_database.call(name, conf)
81
- yield(name, conf)
82
93
  end
83
94
  end
84
95
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phenix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Schambacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-20 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler