phenix 1.0.0 → 1.1.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 +4 -4
- data/lib/phenix/version.rb +1 -1
- data/lib/phenix.rb +21 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae74806ff8278a94e7129e262c977eb9f8a4fe1bdf15f4010aa5c783c726611e
|
4
|
+
data.tar.gz: 257a4f7ad4dc019f64722bed3126147804420e831c9ab4f917027efe9cadf828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b399a58479278268d4135cb1014f798e521ed061a50f22995c6a267a04967805bb6a24bd291bc0d50c0c3288b9ca5002959655f487a6615f21beb0d074c1f99
|
7
|
+
data.tar.gz: eb46bf6ddc58543692f264f644a165669066056c5c703b5761a748fe33fd5961c0fdc3a20a187613f5a9db8a36c3c8fb97eebb4bc14fb3e548127c6a2a47da99
|
data/lib/phenix/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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:
|
11
|
+
date: 2022-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|