ar-octopus 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -8
- data/Appraisals +4 -8
- data/README.mkdn +6 -1
- data/Rakefile +1 -0
- data/ar-octopus.gemspec +4 -4
- data/gemfiles/rails42.gemfile +2 -2
- data/gemfiles/rails5.gemfile +1 -1
- data/gemfiles/rails51.gemfile +1 -1
- data/gemfiles/{rails4.gemfile → rails52.gemfile} +2 -2
- data/lib/octopus.rb +13 -13
- data/lib/octopus/association_shard_tracking.rb +1 -1
- data/lib/octopus/collection_association.rb +1 -1
- data/lib/octopus/migration.rb +102 -61
- data/lib/octopus/model.rb +8 -12
- data/lib/octopus/proxy.rb +32 -11
- data/lib/octopus/proxy_config.rb +7 -8
- data/lib/octopus/query_cache_for_shards.rb +24 -0
- data/lib/octopus/relation_proxy.rb +10 -1
- data/lib/octopus/scope_proxy.rb +1 -1
- data/lib/octopus/version.rb +1 -1
- data/spec/octopus/association_shard_tracking_spec.rb +314 -0
- data/spec/octopus/migration_spec.rb +29 -14
- data/spec/octopus/model_spec.rb +20 -3
- data/spec/octopus/proxy_spec.rb +1 -1
- data/spec/octopus/query_cache_for_shards_spec.rb +40 -0
- data/spec/octopus/replication_spec.rb +57 -2
- data/spec/octopus/scope_proxy_spec.rb +21 -0
- data/spec/support/octopus_helper.rb +13 -4
- metadata +19 -12
- data/gemfiles/rails41.gemfile +0 -7
- data/lib/octopus/has_and_belongs_to_many_association.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 962dc9c9117e08008c637c759626480b47566338
|
4
|
+
data.tar.gz: 8661fb69b2f9fd24df265827eabbc5ee4aa623ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6091ea4584d2c031076b6ea0f4fc06abd9a10c2ed4d88762711d4854c8524c5172bab6081e50bc2a73c8ccf67dc68aeba8d91cdf179cfdc9aa7b77dbff37924
|
7
|
+
data.tar.gz: 96109ec7506bed3e1cd898e2efb1174006d18ca35ee538dbf5e1912fc3d4465188dd7110884ffaff17c2c9fefe126c726e415201e8423e2e957e1dbbaf7bd378
|
data/.travis.yml
CHANGED
@@ -8,18 +8,11 @@ rvm:
|
|
8
8
|
- 2.3.4
|
9
9
|
- 2.4.1
|
10
10
|
gemfile:
|
11
|
-
- gemfiles/rails4.gemfile
|
12
|
-
- gemfiles/rails41.gemfile
|
13
11
|
- gemfiles/rails42.gemfile
|
14
12
|
- gemfiles/rails5.gemfile
|
15
13
|
- gemfiles/rails51.gemfile
|
14
|
+
- gemfiles/rails52.gemfile
|
16
15
|
notifications:
|
17
16
|
recipients:
|
18
17
|
- gabriel.sobrinho@gmail.com
|
19
18
|
- thiago.pradi@gmail.com
|
20
|
-
matrix:
|
21
|
-
exclude:
|
22
|
-
- rvm: 2.4.1
|
23
|
-
gemfile: gemfiles/rails4.gemfile
|
24
|
-
- rvm: 2.4.1
|
25
|
-
gemfile: gemfiles/rails41.gemfile
|
data/Appraisals
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
appraise "rails4" do
|
2
|
-
gem "activerecord", "~> 4.0.0"
|
3
|
-
end
|
4
|
-
|
5
|
-
appraise "rails41" do
|
6
|
-
gem "activerecord", "~> 4.1.0"
|
7
|
-
end
|
8
|
-
|
9
1
|
appraise "rails42" do
|
10
2
|
gem "activerecord", "~> 4.2.0"
|
11
3
|
end
|
@@ -17,4 +9,8 @@ end
|
|
17
9
|
appraise "rails51" do
|
18
10
|
gem "activerecord", "~> 5.1.0"
|
19
11
|
end
|
12
|
+
|
13
|
+
appraise "rails52" do
|
14
|
+
gem "activerecord", "~> 5.2.0"
|
15
|
+
end
|
20
16
|
# vim: ft=ruby
|
data/README.mkdn
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
# Important Notice:
|
2
|
+
|
3
|
+
Octopus will enter into maintainance mode once Rails 6 is released - since Rails 6 will include all the features for Database Sharding / Replication into Rails Core (PR: https://github.com/rails/rails/pull/34052).
|
4
|
+
Once the first version of Rails 6 beta is released, there will be a migration guide to help users migrate from Octopus to Rails 6.
|
5
|
+
|
1
6
|
# Octopus - Easy Database Sharding for ActiveRecord
|
2
7
|
|
3
|
-
|
8
|
+
[![Build Status](https://travis-ci.org/thiagopradi/octopus.svg)](https://travis-ci.org/thiagopradi/octopus) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thiagopradi/octopus)
|
4
9
|
|
5
10
|
Octopus is a better way to do Database Sharding in ActiveRecord. Sharding allows multiple databases in the same rails application. While there are several projects that implement Sharding (e.g. DbCharmer, DataFabric, MultiDb), each project has its own limitations. The main goal of octopus project is to provide a better way of doing Database Sharding.
|
6
11
|
|
data/Rakefile
CHANGED
@@ -65,6 +65,7 @@ namespace :db do
|
|
65
65
|
class BlankModel < ActiveRecord::Base; end
|
66
66
|
|
67
67
|
BlankModel.using(shard_symbol).connection.initialize_schema_migrations_table
|
68
|
+
BlankModel.using(shard_symbol).connection.initialize_metadata_table if Octopus.atleast_rails50?
|
68
69
|
|
69
70
|
BlankModel.using(shard_symbol).connection.create_table(:users) do |u|
|
70
71
|
u.string :name
|
data/ar-octopus.gemspec
CHANGED
@@ -21,13 +21,13 @@ Gem::Specification.new do |s|
|
|
21
21
|
'Octopus now stores schema version information in each shard and migrations will not ' \
|
22
22
|
'work properly unless this task is invoked.'
|
23
23
|
|
24
|
-
s.required_ruby_version = '>= 2.
|
24
|
+
s.required_ruby_version = '>= 2.2.0'
|
25
25
|
|
26
|
-
s.add_dependency 'activerecord', '>= 4.
|
27
|
-
s.add_dependency 'activesupport', '>= 4.
|
26
|
+
s.add_dependency 'activerecord', '>= 4.2.0'
|
27
|
+
s.add_dependency 'activesupport', '>= 4.2.0'
|
28
28
|
|
29
29
|
s.add_development_dependency 'appraisal', '>= 0.3.8'
|
30
|
-
s.add_development_dependency 'mysql2', '
|
30
|
+
s.add_development_dependency 'mysql2', '>= 0.3.18', "< 0.5"
|
31
31
|
s.add_development_dependency 'pg', '~> 0.18'
|
32
32
|
s.add_development_dependency 'rake'
|
33
33
|
s.add_development_dependency 'rspec', '>= 3'
|
data/gemfiles/rails42.gemfile
CHANGED
data/gemfiles/rails5.gemfile
CHANGED
data/gemfiles/rails51.gemfile
CHANGED
data/lib/octopus.rb
CHANGED
@@ -94,18 +94,6 @@ module Octopus
|
|
94
94
|
ActiveRecord::VERSION::MAJOR == 4
|
95
95
|
end
|
96
96
|
|
97
|
-
def self.rails40?
|
98
|
-
rails4? && ActiveRecord::VERSION::MINOR == 0
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.rails41_only?
|
102
|
-
rails4? && ActiveRecord::VERSION::MINOR == 1
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.rails41?
|
106
|
-
rails4? && ActiveRecord::VERSION::MINOR >= 1
|
107
|
-
end
|
108
|
-
|
109
97
|
def self.rails42?
|
110
98
|
rails4? && ActiveRecord::VERSION::MINOR == 2
|
111
99
|
end
|
@@ -113,15 +101,27 @@ module Octopus
|
|
113
101
|
def self.rails50?
|
114
102
|
ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 0
|
115
103
|
end
|
104
|
+
|
105
|
+
def self.atleast_rails50?
|
106
|
+
ActiveRecord::VERSION::MAJOR >= 5
|
107
|
+
end
|
116
108
|
|
117
109
|
def self.rails51?
|
118
110
|
ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 1
|
119
111
|
end
|
120
112
|
|
113
|
+
def self.rails52?
|
114
|
+
ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2
|
115
|
+
end
|
116
|
+
|
121
117
|
def self.atleast_rails51?
|
122
118
|
ActiveRecord::VERSION::MAJOR > 5 || (ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 1)
|
123
119
|
end
|
124
120
|
|
121
|
+
def self.atleast_rails52?
|
122
|
+
ActiveRecord::VERSION::MAJOR > 5 || (ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR > 1)
|
123
|
+
end
|
124
|
+
|
125
125
|
attr_writer :logger
|
126
126
|
|
127
127
|
def self.logger
|
@@ -187,13 +187,13 @@ require 'octopus/result_patch'
|
|
187
187
|
require 'octopus/migration'
|
188
188
|
require 'octopus/association'
|
189
189
|
require 'octopus/collection_association'
|
190
|
-
require 'octopus/has_and_belongs_to_many_association' unless Octopus.rails41? || Octopus.rails50? || Octopus.rails51?
|
191
190
|
require 'octopus/association_shard_tracking'
|
192
191
|
require 'octopus/persistence'
|
193
192
|
require 'octopus/log_subscriber'
|
194
193
|
require 'octopus/abstract_adapter'
|
195
194
|
require 'octopus/singular_association'
|
196
195
|
require 'octopus/finder_methods'
|
196
|
+
require 'octopus/query_cache_for_shards' unless Octopus.rails4?
|
197
197
|
|
198
198
|
require 'octopus/railtie' if defined?(::Rails::Railtie)
|
199
199
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Octopus
|
2
2
|
module CollectionAssociation
|
3
3
|
def self.included(base)
|
4
|
-
if Octopus.rails51?
|
4
|
+
if Octopus.rails51? || Octopus.rails52?
|
5
5
|
base.sharded_methods :reader, :writer, :ids_reader, :ids_writer, :create, :create!,
|
6
6
|
:build, :include?,
|
7
7
|
:load_target, :reload, :size, :select
|
data/lib/octopus/migration.rb
CHANGED
@@ -62,24 +62,26 @@ end
|
|
62
62
|
module Octopus
|
63
63
|
module Migrator
|
64
64
|
def self.included(base)
|
65
|
-
|
66
|
-
|
67
|
-
base.class_eval do
|
68
|
-
class << self
|
69
|
-
alias_method :migrate_without_octopus, :migrate
|
70
|
-
alias_method :migrate, :migrate_with_octopus
|
65
|
+
unless Octopus.atleast_rails52?
|
66
|
+
base.extend(ClassMethods)
|
71
67
|
|
72
|
-
|
73
|
-
|
68
|
+
base.class_eval do
|
69
|
+
class << self
|
70
|
+
alias_method :migrate_without_octopus, :migrate
|
71
|
+
alias_method :migrate, :migrate_with_octopus
|
72
|
+
|
73
|
+
alias_method :up_without_octopus, :up
|
74
|
+
alias_method :up, :up_with_octopus
|
74
75
|
|
75
|
-
|
76
|
-
|
76
|
+
alias_method :down_without_octopus, :down
|
77
|
+
alias_method :down, :down_with_octopus
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
alias_method :run_without_octopus, :run
|
80
|
+
alias_method :run, :run_with_octopus
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
alias_method :rollback_without_octopus, :rollback
|
83
|
+
alias_method :rollback, :rollback_with_octopus
|
84
|
+
end
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
@@ -92,74 +94,113 @@ module Octopus
|
|
92
94
|
base.send :alias_method, :migrations_without_octopus, :migrations
|
93
95
|
base.send :alias_method, :migrations, :migrations_with_octopus
|
94
96
|
end
|
97
|
+
if Octopus.atleast_rails52?
|
98
|
+
### Post RAILS 5.2 Migration methods
|
99
|
+
|
100
|
+
def run_with_octopus(&block)
|
101
|
+
return run_without_octopus(&block) unless connection.is_a?(Octopus::Proxy)
|
102
|
+
shards = migrations.map(&:shards).flatten.map(&:to_s)
|
103
|
+
connection.send_queries_to_multiple_shards(shards) do
|
104
|
+
run_without_octopus(&block)
|
105
|
+
end
|
106
|
+
rescue ActiveRecord::UnknownMigrationVersionError => e
|
107
|
+
raise unless migrations(true).detect { |m| m.version == e.version }
|
108
|
+
end
|
95
109
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
110
|
+
def migrate_with_octopus(&block)
|
111
|
+
return migrate_without_octopus(&block) unless connection.is_a?(Octopus::Proxy)
|
112
|
+
shards = migrations.map(&:shards).flatten.map(&:to_s)
|
113
|
+
connection.send_queries_to_multiple_shards(shards) do
|
114
|
+
migrate_without_octopus(&block)
|
115
|
+
end
|
116
|
+
rescue ActiveRecord::UnknownMigrationVersionError => e
|
117
|
+
raise unless migrations(true).detect { |m| m.version == e.version }
|
118
|
+
end
|
101
119
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
raise unless migrations(true).detect { |m| m.version == e.version }
|
106
|
-
end
|
120
|
+
def migrations_with_octopus(shard_agnostic = true)
|
121
|
+
migrations = migrations_without_octopus
|
122
|
+
return migrations if !connection.is_a?(Octopus::Proxy) || shard_agnostic
|
107
123
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
124
|
+
migrations.select { |m| m.shards.include?(connection.current_shard.to_sym) }
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def connection
|
130
|
+
ActiveRecord::Base.connection
|
131
|
+
end
|
132
|
+
|
133
|
+
else
|
134
|
+
### Pre RAILS 5.2 Migration methods
|
135
|
+
|
136
|
+
def run_with_octopus(&block)
|
137
|
+
run_without_octopus(&block)
|
138
|
+
rescue ActiveRecord::UnknownMigrationVersionError => e
|
139
|
+
raise unless migrations(true).detect { |m| m.version == e.version }
|
140
|
+
end
|
112
141
|
|
113
|
-
|
114
|
-
|
142
|
+
def migrate_with_octopus(&block)
|
143
|
+
migrate_without_octopus(&block)
|
144
|
+
rescue ActiveRecord::UnknownMigrationVersionError => e
|
145
|
+
raise unless migrations(true).detect { |m| m.version == e.version }
|
146
|
+
end
|
115
147
|
|
116
|
-
|
117
|
-
|
118
|
-
|
148
|
+
def migrations_with_octopus(shard_agnostic = false)
|
149
|
+
connection = ActiveRecord::Base.connection
|
150
|
+
migrations = migrations_without_octopus
|
151
|
+
return migrations if !connection.is_a?(Octopus::Proxy) || shard_agnostic
|
119
152
|
|
120
|
-
|
121
|
-
migrate_without_octopus(migrations_paths, target_version, &block)
|
122
|
-
end
|
153
|
+
migrations.select { |m| m.shards.include?(connection.current_shard.to_sym) }
|
123
154
|
end
|
124
155
|
|
125
|
-
|
126
|
-
|
127
|
-
|
156
|
+
module ClassMethods
|
157
|
+
def migrate_with_octopus(migrations_paths, target_version = nil, &block)
|
158
|
+
return migrate_without_octopus(migrations_paths, target_version, &block) unless connection.is_a?(Octopus::Proxy)
|
128
159
|
|
129
|
-
|
130
|
-
|
160
|
+
connection.send_queries_to_multiple_shards(connection.shard_names) do
|
161
|
+
migrate_without_octopus(migrations_paths, target_version, &block)
|
162
|
+
end
|
131
163
|
end
|
132
|
-
end
|
133
164
|
|
134
|
-
|
135
|
-
|
136
|
-
|
165
|
+
def up_with_octopus(migrations_paths, target_version = nil, &block)
|
166
|
+
return up_without_octopus(migrations_paths, target_version, &block) unless connection.is_a?(Octopus::Proxy)
|
167
|
+
return up_without_octopus(migrations_paths, target_version, &block) unless connection.current_shard.to_s == Octopus.master_shard.to_s
|
137
168
|
|
138
|
-
|
139
|
-
|
169
|
+
connection.send_queries_to_multiple_shards(connection.shard_names) do
|
170
|
+
up_without_octopus(migrations_paths, target_version, &block)
|
171
|
+
end
|
140
172
|
end
|
141
|
-
end
|
142
173
|
|
143
|
-
|
144
|
-
|
174
|
+
def down_with_octopus(migrations_paths, target_version = nil, &block)
|
175
|
+
return down_without_octopus(migrations_paths, target_version, &block) unless connection.is_a?(Octopus::Proxy)
|
176
|
+
return down_without_octopus(migrations_paths, target_version, &block) unless connection.current_shard.to_s == Octopus.master_shard.to_s
|
145
177
|
|
146
|
-
|
147
|
-
|
178
|
+
connection.send_queries_to_multiple_shards(connection.shard_names) do
|
179
|
+
down_without_octopus(migrations_paths, target_version, &block)
|
180
|
+
end
|
148
181
|
end
|
149
|
-
end
|
150
182
|
|
151
|
-
|
152
|
-
|
183
|
+
def run_with_octopus(direction, migrations_paths, target_version)
|
184
|
+
return run_without_octopus(direction, migrations_paths, target_version) unless connection.is_a?(Octopus::Proxy)
|
185
|
+
|
186
|
+
connection.send_queries_to_multiple_shards(connection.shard_names) do
|
187
|
+
run_without_octopus(direction, migrations_paths, target_version)
|
188
|
+
end
|
189
|
+
end
|
153
190
|
|
154
|
-
|
155
|
-
rollback_without_octopus(migrations_paths, steps)
|
191
|
+
def rollback_with_octopus(migrations_paths, steps = 1)
|
192
|
+
return rollback_without_octopus(migrations_paths, steps) unless connection.is_a?(Octopus::Proxy)
|
193
|
+
|
194
|
+
connection.send_queries_to_multiple_shards(connection.shard_names) do
|
195
|
+
rollback_without_octopus(migrations_paths, steps)
|
196
|
+
end
|
156
197
|
end
|
157
|
-
end
|
158
198
|
|
159
|
-
|
199
|
+
private
|
160
200
|
|
161
|
-
|
162
|
-
|
201
|
+
def connection
|
202
|
+
ActiveRecord::Base.connection
|
203
|
+
end
|
163
204
|
end
|
164
205
|
end
|
165
206
|
end
|
data/lib/octopus/model.rb
CHANGED
@@ -44,20 +44,16 @@ If you are trying to scope everything to a specific shard, use Octopus.using ins
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def init_with(coder)
|
47
|
-
|
48
|
-
coder['attributes']['current_shard'] if coder['attributes']['current_shard'].present?
|
49
|
-
else
|
50
|
-
coder['attributes']['current_shard'].value if coder['attributes']['current_shard'].present? && coder['attributes']['current_shard'].value.present?
|
51
|
-
end
|
47
|
+
obj = super
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
return obj unless Octopus.enabled?
|
50
|
+
return obj if obj.class.connection_proxy.current_model_replicated?
|
51
|
+
|
52
|
+
current_shard_value = coder['attributes']['current_shard'].value if coder['attributes']['current_shard'].present? && coder['attributes']['current_shard'].value.present?
|
53
|
+
|
54
|
+
coder['attributes'].send(:attributes).send(:values).delete('current_shard')
|
55
|
+
coder['attributes'].send(:attributes).send(:delegate_hash).delete('current_shard')
|
59
56
|
|
60
|
-
obj = super
|
61
57
|
obj.current_shard = current_shard_value if current_shard_value.present?
|
62
58
|
obj
|
63
59
|
end
|
data/lib/octopus/proxy.rb
CHANGED
@@ -26,7 +26,7 @@ module Octopus
|
|
26
26
|
:type_cast, :to_sql, :quote, :quote_column_name, :quote_table_name,
|
27
27
|
:quote_table_name_for_assignment, :supports_migrations?, :table_alias_for,
|
28
28
|
:table_exists?, :in_clause_length, :supports_ddl_transactions?,
|
29
|
-
:sanitize_limit, :prefetch_primary_key?, :current_database,
|
29
|
+
:sanitize_limit, :prefetch_primary_key?, :current_database,
|
30
30
|
:combine_bind_parameters, :empty_insert_statement_value, :assume_migrated_upto_version,
|
31
31
|
:schema_cache, :substitute_at, :internal_string_options_for_primary_key, :lookup_cast_type_from_column,
|
32
32
|
:supports_advisory_locks?, :get_advisory_lock, :initialize_internal_metadata_table,
|
@@ -139,13 +139,15 @@ module Octopus
|
|
139
139
|
shards[current_shard]
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
if Octopus.rails4?
|
143
|
+
def enable_query_cache!
|
144
|
+
clear_query_cache
|
145
|
+
with_each_healthy_shard { |v| v.connected? && safe_connection(v).enable_query_cache! }
|
146
|
+
end
|
146
147
|
|
147
|
-
|
148
|
-
|
148
|
+
def disable_query_cache!
|
149
|
+
with_each_healthy_shard { |v| v.connected? && safe_connection(v).disable_query_cache! }
|
150
|
+
end
|
149
151
|
end
|
150
152
|
|
151
153
|
def clear_query_cache
|
@@ -158,6 +160,13 @@ module Octopus
|
|
158
160
|
|
159
161
|
def clear_all_connections!
|
160
162
|
with_each_healthy_shard(&:disconnect!)
|
163
|
+
|
164
|
+
if Octopus.atleast_rails52?
|
165
|
+
# On Rails 5.2 it is no longer safe to re-use connection pools after they have been discarded
|
166
|
+
# This happens on webservers with forking, for example Phusion Passenger.
|
167
|
+
# Therefor after we clear all connections we reinitialize the shards to get fresh and not discarded ConnectionPool objects
|
168
|
+
proxy_config.reinitialize_shards
|
169
|
+
end
|
161
170
|
end
|
162
171
|
|
163
172
|
def connected?
|
@@ -180,6 +189,22 @@ module Octopus
|
|
180
189
|
send_queries_to_balancer(slave_groups[current_slave_group], method, *args, &block)
|
181
190
|
end
|
182
191
|
|
192
|
+
def current_model_replicated?
|
193
|
+
replicated && (current_model.try(:replicated) || fully_replicated?)
|
194
|
+
end
|
195
|
+
|
196
|
+
def initialize_schema_migrations_table
|
197
|
+
if Octopus.atleast_rails52?
|
198
|
+
select_connection.transaction { ActiveRecord::SchemaMigration.create_table }
|
199
|
+
else
|
200
|
+
select_connection.initialize_schema_migrations_table
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def initialize_metadata_table
|
205
|
+
select_connection.transaction { ActiveRecord::InternalMetadata.create_table }
|
206
|
+
end
|
207
|
+
|
183
208
|
protected
|
184
209
|
|
185
210
|
# @thiagopradi - This legacy method missing logic will be keep for a while for compatibility
|
@@ -247,10 +272,6 @@ module Octopus
|
|
247
272
|
replicated && method.to_s =~ /select/ && !block && !slaves_grouped?
|
248
273
|
end
|
249
274
|
|
250
|
-
def current_model_replicated?
|
251
|
-
replicated && (current_model.try(:replicated) || fully_replicated?)
|
252
|
-
end
|
253
|
-
|
254
275
|
def send_queries_to_selected_slave(method, *args, &block)
|
255
276
|
if current_model.replicated || fully_replicated?
|
256
277
|
selected_slave = slaves_load_balancer.next current_load_balance_options
|