phenix 1.0.0 → 1.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/phenix/version.rb +1 -1
  3. data/lib/phenix.rb +16 -9
  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: 8e08178e36e4d3383fa93d7410ef0b870dd5549e50d69a79c8cf74b7e74d5110
4
+ data.tar.gz: 2387284ebdf301559fb301579254c31f40d279060b14ddb4daf279602656243e
5
5
  SHA512:
6
- metadata.gz: 8b51d7893f9e264814a39c2228d6ac6a4eff7add76727c1d29e61240996dc909bca0de5fdf790b46e31246acb9a90614e024c8625fa7b16cf0f6331c6ea99a3c
7
- data.tar.gz: af507ea35341614a845082df406d3b040c9fb1b5ca31f5d510677b3194855c4d4bb5f61403dad35c1d68bfbe72c0e10312a20fcf11af5da98ebb9241aedc1887
6
+ metadata.gz: 3c56dda05491a697ba6fd0444eacf0b19bbc69e18af43a05d731a5a4d30e41bb21759ab38be6ac23e7cd47e31a04be8cb3cd64d121a36affb1610b691ce2fb3d
7
+ data.tar.gz: 64d70cf6691b14b5b8ccdbcea277f9752daaa08f1652081f72dcc23db0d871d26c5395cd019d62f091b7304b5ce69854a6787eedf01c09892cf771e1fd53931c
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Phenix
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
data/lib/phenix.rb CHANGED
@@ -42,9 +42,15 @@ module Phenix
42
42
  private
43
43
 
44
44
  def create_databases(with_schema)
45
+ # Ensure we've created _every_ database before attempting to populte them
46
+ # This avoids ActiveRecord caching issues if the cache maintains references
47
+ # to stale databases
45
48
  for_each_database do |name, conf|
46
49
  run_mysql_command(conf, "CREATE DATABASE IF NOT EXISTS #{conf['database']}")
47
- ActiveRecord::Base.establish_connection(name.to_sym)
50
+ end
51
+
52
+ for_each_database do |name, conf|
53
+ ActiveRecord::Base.establish_connection(conf)
48
54
  populate_database if with_schema
49
55
  end
50
56
  end
@@ -64,7 +70,15 @@ module Phenix
64
70
  end
65
71
 
66
72
  def for_each_database
67
- configuration_hashes = if ActiveRecord::VERSION::STRING < '6.1'
73
+ parse_configuration_hashes.each do |name, conf|
74
+ next if conf['database'].nil?
75
+ next if Phenix.skip_database.call(name, conf)
76
+ yield(name, conf)
77
+ end
78
+ end
79
+
80
+ def parse_configuration_hashes
81
+ if ActiveRecord::VERSION::STRING < '6.1'
68
82
  ActiveRecord::Base.configurations.to_h
69
83
  else
70
84
  # We need to get all the configurations and put them back into a hash
@@ -72,13 +86,6 @@ module Phenix
72
86
  ActiveRecord::Base.configurations
73
87
  .configurations
74
88
  .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
89
  end
83
90
  end
84
91
 
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.0.1
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-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler