multi-database-9000 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a298c8a6e8b9f13f7693a6e095d599f887e727
|
4
|
+
data.tar.gz: 99c365b6c7cc7f69496a5fa1b284b637cb914f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9396097551db4202e83fd6239cc5dee511984a3e39b1c455237912f455d840fb0afc58fab81b3b1e777f1bc6534999148570ca0864e4263e76192249071473f0
|
7
|
+
data.tar.gz: 6e464b44a392dbd32383e007eed10e5e0bdcba847bd2b4dbd63f573625f0c27406deea76bfd16798a2669163f285434e850a870241bad7be0c9ea4b7d3d0021c
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module MultiDatabase9000
|
2
2
|
def self.maintain_all_test_schemas!
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
if ActiveRecord::Migrator.needs_migration? || !ActiveRecord::Migrator.any_migrations?
|
4
|
+
# Roundrip to Rake to allow plugins to hook into database initialization.
|
5
|
+
FileUtils.cd Rails.root do
|
6
|
+
current_config = ActiveRecord::Base.connection_config
|
7
|
+
ActiveRecord::Base.clear_all_connections!
|
8
|
+
system("bin/rake db:test:prepare")
|
9
|
+
# Establish a new connection, the old database may be gone (db:test:prepare uses purge)
|
10
|
+
ActiveRecord::Base.establish_connection(current_config)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
def database_connections(database: nil, rails_envs: nil)
|
3
2
|
connections = connections_for_environment(rails_envs)
|
4
3
|
if database.present?
|
@@ -7,9 +6,9 @@ def database_connections(database: nil, rails_envs: nil)
|
|
7
6
|
return connections
|
8
7
|
end
|
9
8
|
|
10
|
-
def connections_for_environment(rails_envs)
|
9
|
+
def connections_for_environment(rails_envs, include_default_env: true)
|
11
10
|
rails_envs = Array(rails_envs)
|
12
|
-
matcher = ->(key,
|
11
|
+
matcher = ->(key, _){rails_envs.any?{|env| key.match(Regexp.new(env)) && (include_default_env || env != key)}}
|
13
12
|
return ActiveRecord::Base.configurations.keep_if &matcher
|
14
13
|
end
|
15
14
|
|
@@ -46,7 +45,7 @@ Rake::Task['db:migrate:status'].clear
|
|
46
45
|
Rake::Task["db:test:load_schema"].enhance do
|
47
46
|
begin
|
48
47
|
should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
|
49
|
-
connections_for_environment("test").each do |connection_key, connection|
|
48
|
+
connections_for_environment("test", include_default_env: false).each do |connection_key, connection|
|
50
49
|
ActiveRecord::Tasks::DatabaseTasks.load_schema_for connection, :ruby, "db/#{schema_file_name(connection_key)}"
|
51
50
|
end
|
52
51
|
ensure
|
data/multi-db-dummy/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi-database-9000
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Weston
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
requirements: []
|
287
287
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.
|
288
|
+
rubygems_version: 2.5.1
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: Enables Rails apps with multiple databases to handle migrations and rake
|