tako 0.5.0 → 0.6.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: d8b2c4e33550d99d32fba6703d7f4904bff9c2a4
4
- data.tar.gz: a121f0faf4ccac973896d70de11fde63859b738c
3
+ metadata.gz: d8c09725ee3badc216ffb331810b51c2583e3136
4
+ data.tar.gz: c0c076d271e624f1ce71e023ff3c876b56df32ad
5
5
  SHA512:
6
- metadata.gz: 47b3f5f903b7de5805d1a430da319722fe0f5a83b18ef6e6884f6b675ceed132c823fc05628301ef3dcc6373e2c06aa3d52fc0d00a11b93d7a5f1894e86dfb39
7
- data.tar.gz: 58cd2e7a31e8d5bacba4a78e1744e595056d31724fbbba3b6f302dcefb7fb6ae985ea97c791e177b6829ef43597072d6e480982a837489ce23944240bf786696
6
+ metadata.gz: 68cb0d10411f90ccadeca75eba70a97a5dc9f17b750710f513f4a37ab146056ae841140530d299a08c40f76ba9e70823277a653d96858597667b3715fc1a71f6
7
+ data.tar.gz: 6e3570f94b6f0714252a24d3a6cd91b633f0fcf898e80d14c0d39cee2d9b3b6569e8278de975d5b03dc17920b8a6ba70ad86ce5c9c6b1a2640589fe326a1fb54
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 4.2.0"
3
+ gem "rails", "~> 4.2.0"
4
4
  gem "mysql2", ">= 0.3.13", "< 0.5"
5
5
 
6
6
  gemspec :path => "../"
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 5.0.0"
3
+ gem "rails", "~> 5.0.0"
4
4
 
5
5
  gemspec :path => "../"
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 5.1.0"
3
+ gem "rails", "~> 5.1.0"
4
4
 
5
5
  gemspec :path => "../"
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "activerecord", "~> 5.2.0"
3
+ gem "rails", "~> 5.2.0"
4
4
 
5
5
  gemspec :path => "../"
@@ -2,6 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
4
 
5
- gem "activerecord", :github => "rails/rails"
5
+ gem "rails", :github => "rails/rails"
6
6
 
7
7
  gemspec :path => "../"
@@ -14,5 +14,6 @@ module Tako
14
14
  end
15
15
 
16
16
  ActiveRecord::ConnectionHandling.class_eval do
17
+ alias_method :connection_without_tako, :connection
17
18
  prepend Tako::ActiveRecordExt::ConnectionHandling
18
19
  end
@@ -31,11 +31,12 @@ namespace :db do
31
31
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
32
32
  revert = !!ENV["DOWN_MIGRATION"]
33
33
 
34
- migrations = if version
35
- ActiveRecord::Migrator.migrations(paths).select {|proxy| proxy.version == version }
34
+ migrations = if defined?(ActiveRecord::MigrationContext)
35
+ ActiveRecord::MigrationContext.new(paths).migrations
36
36
  else
37
37
  ActiveRecord::Migrator.migrations(paths)
38
38
  end
39
+ migrations.select! {|proxy| proxy.version == version } if version
39
40
  all_schema_migration_versions = ActiveRecord::SchemaMigration.pluck(:version)
40
41
  migrations = migrations.reject {|proxy| all_schema_migration_versions.include?(proxy.version.to_s) }
41
42
  migrations.each do |proxy|
@@ -49,7 +50,11 @@ namespace :db do
49
50
 
50
51
  if defined?(ActiveRecord::InternalMetadata)
51
52
  ActiveRecord::InternalMetadata.create_table
52
- ActiveRecord::InternalMetadata[:environment] = ActiveRecord::Migrator.current_environment
53
+ ActiveRecord::InternalMetadata[:environment] = if defined?(ActiveRecord::MigrationContext)
54
+ ActiveRecord::MigrationContext.new(paths).current_environment
55
+ else
56
+ ActiveRecord::Migrator.current_environment
57
+ end
53
58
  end
54
59
  end
55
60
  end
@@ -5,17 +5,17 @@ module Tako
5
5
  @proxy_configs ||= {}
6
6
  end
7
7
 
8
- def proxy_connections
9
- @proxy_connections ||= {}
8
+ def proxy_classes
9
+ @proxy_classes ||= {}
10
10
  end
11
11
 
12
12
  def clear
13
- proxy_connections.each do |shard_name, connection|
14
- connection.disconnect!
13
+ proxy_classes.each do |shard_name, proxy_class|
14
+ proxy_class.connection.disconnect!
15
15
  remove_const("TAKO_AR_CLASS_#{shard_name.upcase}")
16
16
  end
17
17
  proxy_configs.clear
18
- proxy_connections.clear
18
+ proxy_classes.clear
19
19
  end
20
20
 
21
21
  def add(shard_name, conf)
@@ -26,12 +26,12 @@ module Tako
26
26
  const_set("TAKO_AR_CLASS_#{shard_name.upcase}", temporary_class)
27
27
  temporary_class.establish_connection(conf)
28
28
 
29
- proxy_connections[shard_name] = temporary_class.connection
29
+ proxy_classes[shard_name] = temporary_class
30
30
  proxy_configs[shard_name] = conf
31
31
  end
32
32
 
33
33
  def create_proxy(shard_name)
34
- Proxy.new(shard_name, proxy_connections[shard_name.to_sym])
34
+ Proxy.new(shard_name, proxy_classes[shard_name.to_sym].connection_without_tako)
35
35
  end
36
36
 
37
37
  def shard_names
@@ -1,3 +1,3 @@
1
1
  module Tako
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tako
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masashi AKISUE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord