multi-database-9000 0.3.2 → 0.4.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
  SHA1:
3
- metadata.gz: c941f8e97928fc6d86a81f4b07b552e2d832516f
4
- data.tar.gz: 114253f571df29eb17201088b45451a20606f10d
3
+ metadata.gz: a9a298c8a6e8b9f13f7693a6e095d599f887e727
4
+ data.tar.gz: 99c365b6c7cc7f69496a5fa1b284b637cb914f0c
5
5
  SHA512:
6
- metadata.gz: 4ab393c65e0ce9ff0248fa8f58b8e1d608d9f91abf6de8c16f7a2c26f1de8bf4a487c9cda5cbc08ee2a725c863ea42192a68dac2cff16dc1e0781958534d1a89
7
- data.tar.gz: d15b57dfe902c132efa8823add10f40aa3c1dbf83a411bf4703d92306246a3a00640f26ab8dc53ec9e3bb7e3308e1dba92865b9f598420d0eb71595f7720e526
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
- # Roundrip to Rake to allow plugins to hook into database initialization.
4
- FileUtils.cd Rails.root do
5
- current_config = ActiveRecord::Base.connection_config
6
- ActiveRecord::Base.clear_all_connections!
7
- system("bin/rake db:test:prepare")
8
- # Establish a new connection, the old database may be gone (db:test:prepare uses purge)
9
- ActiveRecord::Base.establish_connection(current_config)
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, value){rails_envs.any?{|env| key.match Regexp.new(env)}}
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
@@ -1,3 +1,3 @@
1
1
  module MultiDatabase9000
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- multi-database-9000 (0.3.0)
4
+ multi-database-9000 (0.3.2)
5
5
  rails (>= 4.0)
6
6
 
7
7
  GEM
@@ -113,3 +113,6 @@ DEPENDENCIES
113
113
  pry
114
114
  rails (= 4.2.4)
115
115
  sqlite3
116
+
117
+ BUNDLED WITH
118
+ 1.11.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- multi-database-9000 (0.3.0)
4
+ multi-database-9000 (0.3.2)
5
5
  rails (>= 4.0)
6
6
 
7
7
  GEM
@@ -113,3 +113,6 @@ DEPENDENCIES
113
113
  pry
114
114
  rails (= 4.2.4)
115
115
  sqlite3
116
+
117
+ BUNDLED WITH
118
+ 1.11.2
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.3.2
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: 2015-11-17 00:00:00.000000000 Z
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.4.5
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