active_record_shards 3.0.0.beta4 → 3.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.
@@ -10,6 +10,7 @@ require 'active_record_shards/migration'
10
10
  require 'active_record_shards/default_slave_patches'
11
11
  require 'active_record_shards/connection_handler'
12
12
  require 'active_record_shards/connection_specification'
13
+ require 'active_record_shards/schema_dumper_extension'
13
14
 
14
15
  if ActiveRecord::VERSION::MAJOR >= 4
15
16
  methods_to_override = [:establish_connection, :remove_connection, :pool_for,
@@ -37,6 +38,10 @@ end
37
38
 
38
39
  ActiveRecord::Associations::CollectionProxy.send(:include, ActiveRecordShards::AssociationCollectionConnectionSelection)
39
40
 
41
+ if ActiveRecord::VERSION::MAJOR >= 4 && RUBY_VERSION >= '2'
42
+ ActiveRecord::SchemaDumper.send(:prepend, ActiveRecordShards::SchemaDumperExtension)
43
+ end
44
+
40
45
  module ActiveRecordShards
41
46
  def self.rails_env
42
47
  env = Rails.env if Object.const_defined?(:Rails)
@@ -0,0 +1,43 @@
1
+ module ActiveRecordShards
2
+ module SchemaDumperExtension
3
+
4
+ def dump(stream)
5
+ stream = super(stream)
6
+ original_connection = @connection
7
+
8
+ if ActiveRecord::Base.supports_sharding?
9
+ ActiveRecord::Base.on_first_shard do
10
+ @connection = ActiveRecord::Base.connection
11
+ shard_header(stream)
12
+ extensions(stream)
13
+ tables(stream)
14
+ shard_trailer(stream)
15
+ end
16
+ end
17
+
18
+ stream
19
+ ensure
20
+ @connection = original_connection
21
+ end
22
+
23
+
24
+ def shard_header(stream)
25
+ define_params = @version ? "version: #{@version}" : ""
26
+
27
+ stream.puts <<HEADER
28
+
29
+
30
+ # This section generated by active_record_shards
31
+
32
+ ActiveRecord::Base.on_all_shards do
33
+ ActiveRecord::Schema.define(#{define_params}) do
34
+
35
+ HEADER
36
+ end
37
+
38
+ def shard_trailer(stream)
39
+ stream.puts "end\nend"
40
+ end
41
+
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta4
4
+ version: 3.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Mick Staugaard
@@ -10,26 +11,28 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-06-05 00:00:00.000000000 Z
14
+ date: 2014-07-09 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activerecord
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - ">="
21
+ - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
23
  version: 3.2.16
22
- - - "<="
24
+ - - <=
23
25
  - !ruby/object:Gem::Version
24
26
  version: '4.1'
25
27
  type: :runtime
26
28
  prerelease: false
27
29
  version_requirements: !ruby/object:Gem::Requirement
30
+ none: false
28
31
  requirements:
29
- - - ">="
32
+ - - ! '>='
30
33
  - !ruby/object:Gem::Version
31
34
  version: 3.2.16
32
- - - "<="
35
+ - - <=
33
36
  - !ruby/object:Gem::Version
34
37
  version: '4.1'
35
38
  description: Easily run queries on shard and slave databases.
@@ -41,8 +44,6 @@ executables: []
41
44
  extensions: []
42
45
  extra_rdoc_files: []
43
46
  files:
44
- - README.md
45
- - lib/active_record_shards.rb
46
47
  - lib/active_record_shards/association_collection_connection_selection.rb
47
48
  - lib/active_record_shards/configuration_parser.rb
48
49
  - lib/active_record_shards/connection_handler.rb
@@ -52,30 +53,34 @@ files:
52
53
  - lib/active_record_shards/default_slave_patches.rb
53
54
  - lib/active_record_shards/migration.rb
54
55
  - lib/active_record_shards/model.rb
56
+ - lib/active_record_shards/schema_dumper_extension.rb
55
57
  - lib/active_record_shards/shard_selection.rb
56
58
  - lib/active_record_shards/tasks.rb
59
+ - lib/active_record_shards.rb
60
+ - README.md
57
61
  homepage: https://github.com/zendesk/active_record_shards
58
62
  licenses:
59
63
  - MIT
60
- metadata: {}
61
64
  post_install_message:
62
65
  rdoc_options: []
63
66
  require_paths:
64
67
  - lib
65
68
  required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
66
70
  requirements:
67
- - - ">="
71
+ - - ! '>='
68
72
  - !ruby/object:Gem::Version
69
73
  version: '0'
70
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
71
76
  requirements:
72
- - - ">"
77
+ - - ! '>='
73
78
  - !ruby/object:Gem::Version
74
- version: 1.3.1
79
+ version: '0'
75
80
  requirements: []
76
81
  rubyforge_project:
77
- rubygems_version: 2.2.2
82
+ rubygems_version: 1.8.23.2
78
83
  signing_key:
79
- specification_version: 4
84
+ specification_version: 3
80
85
  summary: Simple database switching for ActiveRecord.
81
86
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 6e2b0d1263e6c2ba07f208b1c46f252e254cd341
4
- data.tar.gz: b5e951385e67395baaf4e6408441fda6350afc1f
5
- SHA512:
6
- metadata.gz: f194e8c0726304edff05e03f501b8edf42dff62ea28bdbe90293b93d10cae94499471934387401682dcb7b69f63f5c4eeb428b14ea91da11d3c54a78d964a4e5
7
- data.tar.gz: c87fd04a0217d32e9399f58b9f45d6f9e483444e21285c0d1ad29bf4baad3c6c165d988c3b3fd7800db7a950f63efa8a4f0d829a9c13290fec381230573661bc