ar-octopus-ruby-3 0.11.2

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.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +46 -0
  5. data/.rubocop_todo.yml +56 -0
  6. data/.travis.yml +18 -0
  7. data/Appraisals +16 -0
  8. data/Gemfile +4 -0
  9. data/README.mkdn +257 -0
  10. data/Rakefile +175 -0
  11. data/TODO.txt +7 -0
  12. data/ar-octopus.gemspec +44 -0
  13. data/gemfiles/rails42.gemfile +7 -0
  14. data/gemfiles/rails5.gemfile +7 -0
  15. data/gemfiles/rails51.gemfile +7 -0
  16. data/gemfiles/rails52.gemfile +7 -0
  17. data/lib/ar-octopus.rb +1 -0
  18. data/lib/octopus/abstract_adapter.rb +33 -0
  19. data/lib/octopus/association.rb +14 -0
  20. data/lib/octopus/association_shard_tracking.rb +74 -0
  21. data/lib/octopus/collection_association.rb +17 -0
  22. data/lib/octopus/collection_proxy.rb +16 -0
  23. data/lib/octopus/exception.rb +4 -0
  24. data/lib/octopus/finder_methods.rb +8 -0
  25. data/lib/octopus/load_balancing/round_robin.rb +20 -0
  26. data/lib/octopus/load_balancing.rb +4 -0
  27. data/lib/octopus/log_subscriber.rb +26 -0
  28. data/lib/octopus/migration.rb +236 -0
  29. data/lib/octopus/model.rb +216 -0
  30. data/lib/octopus/persistence.rb +45 -0
  31. data/lib/octopus/proxy.rb +399 -0
  32. data/lib/octopus/proxy_config.rb +251 -0
  33. data/lib/octopus/query_cache_for_shards.rb +24 -0
  34. data/lib/octopus/railtie.rb +11 -0
  35. data/lib/octopus/relation_proxy.rb +74 -0
  36. data/lib/octopus/result_patch.rb +19 -0
  37. data/lib/octopus/scope_proxy.rb +68 -0
  38. data/lib/octopus/shard_tracking/attribute.rb +22 -0
  39. data/lib/octopus/shard_tracking/dynamic.rb +11 -0
  40. data/lib/octopus/shard_tracking.rb +46 -0
  41. data/lib/octopus/singular_association.rb +9 -0
  42. data/lib/octopus/slave_group.rb +13 -0
  43. data/lib/octopus/version.rb +3 -0
  44. data/lib/octopus.rb +209 -0
  45. data/lib/tasks/octopus.rake +16 -0
  46. data/sample_app/.gitignore +4 -0
  47. data/sample_app/.rspec +1 -0
  48. data/sample_app/Gemfile +20 -0
  49. data/sample_app/Gemfile.lock +155 -0
  50. data/sample_app/README +3 -0
  51. data/sample_app/README.rdoc +261 -0
  52. data/sample_app/Rakefile +7 -0
  53. data/sample_app/app/assets/images/rails.png +0 -0
  54. data/sample_app/app/assets/javascripts/application.js +15 -0
  55. data/sample_app/app/assets/stylesheets/application.css +13 -0
  56. data/sample_app/app/controllers/application_controller.rb +4 -0
  57. data/sample_app/app/helpers/application_helper.rb +2 -0
  58. data/sample_app/app/mailers/.gitkeep +0 -0
  59. data/sample_app/app/models/.gitkeep +0 -0
  60. data/sample_app/app/models/item.rb +3 -0
  61. data/sample_app/app/models/user.rb +3 -0
  62. data/sample_app/app/views/layouts/application.html.erb +14 -0
  63. data/sample_app/autotest/discover.rb +2 -0
  64. data/sample_app/config/application.rb +62 -0
  65. data/sample_app/config/boot.rb +6 -0
  66. data/sample_app/config/cucumber.yml +8 -0
  67. data/sample_app/config/database.yml +28 -0
  68. data/sample_app/config/environment.rb +5 -0
  69. data/sample_app/config/environments/development.rb +37 -0
  70. data/sample_app/config/environments/production.rb +67 -0
  71. data/sample_app/config/environments/test.rb +37 -0
  72. data/sample_app/config/initializers/backtrace_silencers.rb +7 -0
  73. data/sample_app/config/initializers/inflections.rb +15 -0
  74. data/sample_app/config/initializers/mime_types.rb +5 -0
  75. data/sample_app/config/initializers/secret_token.rb +7 -0
  76. data/sample_app/config/initializers/session_store.rb +8 -0
  77. data/sample_app/config/initializers/wrap_parameters.rb +14 -0
  78. data/sample_app/config/locales/en.yml +5 -0
  79. data/sample_app/config/routes.rb +58 -0
  80. data/sample_app/config/shards.yml +28 -0
  81. data/sample_app/config.ru +4 -0
  82. data/sample_app/db/migrate/20100720172715_create_users.rb +15 -0
  83. data/sample_app/db/migrate/20100720172730_create_items.rb +16 -0
  84. data/sample_app/db/migrate/20100720210335_create_sample_users.rb +11 -0
  85. data/sample_app/db/schema.rb +29 -0
  86. data/sample_app/db/seeds.rb +16 -0
  87. data/sample_app/doc/README_FOR_APP +2 -0
  88. data/sample_app/features/migrate.feature +45 -0
  89. data/sample_app/features/seed.feature +15 -0
  90. data/sample_app/features/step_definitions/seeds_steps.rb +13 -0
  91. data/sample_app/features/step_definitions/web_steps.rb +218 -0
  92. data/sample_app/features/support/database.rb +13 -0
  93. data/sample_app/features/support/env.rb +57 -0
  94. data/sample_app/features/support/paths.rb +33 -0
  95. data/sample_app/lib/assets/.gitkeep +0 -0
  96. data/sample_app/lib/tasks/.gitkeep +0 -0
  97. data/sample_app/lib/tasks/cucumber.rake +64 -0
  98. data/sample_app/log/.gitkeep +0 -0
  99. data/sample_app/public/404.html +26 -0
  100. data/sample_app/public/422.html +26 -0
  101. data/sample_app/public/500.html +26 -0
  102. data/sample_app/public/favicon.ico +0 -0
  103. data/sample_app/public/images/rails.png +0 -0
  104. data/sample_app/public/index.html +279 -0
  105. data/sample_app/public/javascripts/application.js +2 -0
  106. data/sample_app/public/javascripts/controls.js +965 -0
  107. data/sample_app/public/javascripts/dragdrop.js +974 -0
  108. data/sample_app/public/javascripts/effects.js +1123 -0
  109. data/sample_app/public/javascripts/prototype.js +4874 -0
  110. data/sample_app/public/javascripts/rails.js +118 -0
  111. data/sample_app/public/robots.txt +5 -0
  112. data/sample_app/public/stylesheets/.gitkeep +0 -0
  113. data/sample_app/script/cucumber +10 -0
  114. data/sample_app/script/rails +6 -0
  115. data/sample_app/spec/models/item_spec.rb +5 -0
  116. data/sample_app/spec/models/user_spec.rb +5 -0
  117. data/sample_app/spec/spec_helper.rb +27 -0
  118. data/sample_app/vendor/assets/javascripts/.gitkeep +0 -0
  119. data/sample_app/vendor/assets/stylesheets/.gitkeep +0 -0
  120. data/sample_app/vendor/plugins/.gitkeep +0 -0
  121. data/spec/config/shards.yml +231 -0
  122. data/spec/migrations/10_create_users_using_replication.rb +9 -0
  123. data/spec/migrations/11_add_field_in_all_slaves.rb +11 -0
  124. data/spec/migrations/12_create_users_using_block.rb +23 -0
  125. data/spec/migrations/13_create_users_using_block_and_using.rb +15 -0
  126. data/spec/migrations/14_create_users_on_shards_of_a_group_with_versions.rb +11 -0
  127. data/spec/migrations/15_create_user_on_shards_of_default_group_with_versions.rb +9 -0
  128. data/spec/migrations/1_create_users_on_master.rb +9 -0
  129. data/spec/migrations/2_create_users_on_canada.rb +11 -0
  130. data/spec/migrations/3_create_users_on_both_shards.rb +11 -0
  131. data/spec/migrations/4_create_users_on_shards_of_a_group.rb +11 -0
  132. data/spec/migrations/5_create_users_on_multiples_groups.rb +11 -0
  133. data/spec/migrations/6_raise_exception_with_invalid_shard_name.rb +11 -0
  134. data/spec/migrations/7_raise_exception_with_invalid_multiple_shard_names.rb +11 -0
  135. data/spec/migrations/8_raise_exception_with_invalid_group_name.rb +11 -0
  136. data/spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb +11 -0
  137. data/spec/octopus/association_shard_tracking_spec.rb +1036 -0
  138. data/spec/octopus/collection_proxy_spec.rb +16 -0
  139. data/spec/octopus/load_balancing/round_robin_spec.rb +15 -0
  140. data/spec/octopus/log_subscriber_spec.rb +19 -0
  141. data/spec/octopus/migration_spec.rb +151 -0
  142. data/spec/octopus/model_spec.rb +837 -0
  143. data/spec/octopus/octopus_spec.rb +123 -0
  144. data/spec/octopus/proxy_spec.rb +303 -0
  145. data/spec/octopus/query_cache_for_shards_spec.rb +40 -0
  146. data/spec/octopus/relation_proxy_spec.rb +132 -0
  147. data/spec/octopus/replicated_slave_grouped_spec.rb +91 -0
  148. data/spec/octopus/replication_spec.rb +196 -0
  149. data/spec/octopus/scope_proxy_spec.rb +97 -0
  150. data/spec/octopus/sharded_replicated_slave_grouped_spec.rb +55 -0
  151. data/spec/octopus/sharded_spec.rb +33 -0
  152. data/spec/spec_helper.rb +18 -0
  153. data/spec/support/active_record/connection_adapters/modify_config_adapter.rb +15 -0
  154. data/spec/support/database_connection.rb +4 -0
  155. data/spec/support/database_models.rb +118 -0
  156. data/spec/support/octopus_helper.rb +66 -0
  157. data/spec/support/query_count.rb +17 -0
  158. data/spec/support/shared_contexts.rb +18 -0
  159. data/spec/tasks/octopus.rake_spec.rb +32 -0
  160. metadata +351 -0
@@ -0,0 +1,118 @@
1
+ document.observe("dom:loaded", function() {
2
+ function handleRemote(element) {
3
+ var method, url, params;
4
+
5
+ if (element.tagName.toLowerCase() === 'form') {
6
+ method = element.readAttribute('method') || 'post';
7
+ url = element.readAttribute('action');
8
+ params = element.serialize(true);
9
+ } else {
10
+ method = element.readAttribute('data-method') || 'get';
11
+ url = element.readAttribute('href');
12
+ params = {};
13
+ }
14
+
15
+ var event = element.fire("ajax:before");
16
+ if (event.stopped) return false;
17
+
18
+ new Ajax.Request(url, {
19
+ method: method,
20
+ parameters: params,
21
+ asynchronous: true,
22
+ evalScripts: true,
23
+
24
+ onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
25
+ onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
26
+ onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
27
+ onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
28
+ onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
29
+ onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
30
+ });
31
+
32
+ element.fire("ajax:after");
33
+ }
34
+
35
+ function handleMethod(element) {
36
+ var method, url, token_name, token;
37
+
38
+ method = element.readAttribute('data-method');
39
+ url = element.readAttribute('href');
40
+ csrf_param = $$('meta[name=csrf-param]').first();
41
+ csrf_token = $$('meta[name=csrf-token]').first();
42
+
43
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
44
+ element.parentNode.appendChild(form);
45
+
46
+ if (method != 'post') {
47
+ var field = new Element('input', { type: 'hidden', name: '_method', value: method });
48
+ form.appendChild(field);
49
+ }
50
+
51
+ if (csrf_param) {
52
+ var param = csrf_param.readAttribute('content');
53
+ var token = csrf_token.readAttribute('content');
54
+ var field = new Element('input', { type: 'hidden', name: param, value: token });
55
+ form.appendChild(field);
56
+ }
57
+
58
+ form.submit();
59
+ }
60
+
61
+ $(document.body).observe("click", function(event) {
62
+ var message = event.findElement().readAttribute('data-confirm');
63
+ if (message && !confirm(message)) {
64
+ event.stop();
65
+ return false;
66
+ }
67
+
68
+ var element = event.findElement("a[data-remote]");
69
+ if (element) {
70
+ handleRemote(element);
71
+ event.stop();
72
+ return true;
73
+ }
74
+
75
+ var element = event.findElement("a[data-method]");
76
+ if (element) {
77
+ handleMethod(element);
78
+ event.stop();
79
+ return true;
80
+ }
81
+ });
82
+
83
+ // TODO: I don't think submit bubbles in IE
84
+ $(document.body).observe("submit", function(event) {
85
+ var element = event.findElement(),
86
+ message = element.readAttribute('data-confirm');
87
+ if (message && !confirm(message)) {
88
+ event.stop();
89
+ return false;
90
+ }
91
+
92
+ var inputs = element.select("input[type=submit][data-disable-with]");
93
+ inputs.each(function(input) {
94
+ input.disabled = true;
95
+ input.writeAttribute('data-original-value', input.value);
96
+ input.value = input.readAttribute('data-disable-with');
97
+ });
98
+
99
+ var element = event.findElement("form[data-remote]");
100
+ if (element) {
101
+ handleRemote(element);
102
+ event.stop();
103
+ }
104
+ });
105
+
106
+ $(document.body).observe("ajax:after", function(event) {
107
+ var element = event.findElement();
108
+
109
+ if (element.tagName.toLowerCase() === 'form') {
110
+ var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
111
+ inputs.each(function(input) {
112
+ input.value = input.readAttribute('data-original-value');
113
+ input.writeAttribute('data-original-value', null);
114
+ input.disabled = false;
115
+ });
116
+ }
117
+ });
118
+ });
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Item do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
@@ -0,0 +1,27 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require File.expand_path('../../config/environment', __FILE__)
5
+ require 'rspec/rails'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ config.mock_with :rspec
20
+
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, comment the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,231 @@
1
+ mysql: &mysql
2
+ adapter: mysql2
3
+ username: <%= ENV['MYSQL_USER'] || 'root' %>
4
+ host: localhost
5
+ password: '1234'
6
+
7
+ mysql_unavailable: &mysql_unavailable
8
+ adapter: mysql2
9
+ username: <%= ENV['MYSQL_USER'] || 'root' %>
10
+ host: 192.0.2.1
11
+ connect_timeout: 3
12
+ password: '1234'
13
+
14
+ octopus: &octopus
15
+ shards:
16
+ alone_shard:
17
+ database: octopus_shard_5
18
+ <<: *mysql
19
+
20
+ postgresql_shard:
21
+ adapter: postgresql
22
+ username: <%= ENV['POSTGRES_USER'] || 'daniel' %>
23
+ password: '1234'
24
+ database: octopus_shard_1
25
+ encoding: unicode
26
+ host: ''
27
+
28
+ sqlite_shard:
29
+ adapter: sqlite3
30
+ database: /tmp/database.sqlite3
31
+
32
+ history_shards:
33
+ aug2009:
34
+ database: octopus_shard_2
35
+ <<: *mysql
36
+ aug2010:
37
+ database: octopus_shard_3
38
+ <<: *mysql
39
+ aug2011:
40
+ database: octopus_shard_4
41
+ <<: *mysql
42
+
43
+ country_shards:
44
+ canada:
45
+ database: octopus_shard_2
46
+ <<: *mysql
47
+ brazil:
48
+ database: octopus_shard_3
49
+ <<: *mysql
50
+ russia:
51
+ database: octopus_shard_4
52
+ <<: *mysql
53
+
54
+ protocol_shard: postgres://<%= ENV['POSTGRES_USER'] || 'postgres' %>@localhost:5432/octopus_shard_2
55
+
56
+ octopus_with_default_migration_group:
57
+ <<: *octopus
58
+ default_migration_group: country_shards
59
+
60
+ production_raise_error:
61
+ shards:
62
+ history_shards:
63
+ duplicated_shard_name:
64
+ database: octopus_shard_5
65
+ <<: *mysql
66
+
67
+ country_shards:
68
+ duplicated_shard_name:
69
+ database: octopus_shard_4
70
+ <<: *mysql
71
+
72
+ production_replicated:
73
+ replicated: true
74
+ fully_replicated: false
75
+
76
+ shards:
77
+ slave1:
78
+ database: octopus_shard_2
79
+ <<: *mysql
80
+ slave2:
81
+ database: octopus_shard_3
82
+ <<: *mysql
83
+ slave3:
84
+ database: octopus_shard_4
85
+ <<: *mysql
86
+ slave4:
87
+ database: octopus_shard_5
88
+ <<: *mysql
89
+
90
+
91
+ production_fully_replicated:
92
+ replicated: true
93
+ fully_replicated: true
94
+
95
+ shards:
96
+ slave1:
97
+ database: octopus_shard_2
98
+ <<: *mysql
99
+ slave2:
100
+ database: octopus_shard_3
101
+ <<: *mysql
102
+
103
+ replicated_with_one_slave:
104
+ replicated: true
105
+ shards:
106
+ slave1:
107
+ database: octopus_shard_2
108
+ <<: *mysql
109
+
110
+ replicated_with_one_slave_unavailable:
111
+ replicated: true
112
+ shards:
113
+ slave1:
114
+ database: octopus_shard_2
115
+ <<: *mysql_unavailable
116
+
117
+
118
+ production_fully_replicated:
119
+ replicated: true
120
+ shards:
121
+ slave1:
122
+ database: octopus_shard_2
123
+ <<: *mysql
124
+ slave2:
125
+ database: octopus_shard_3
126
+ <<: *mysql
127
+ slave3:
128
+ database: octopus_shard_4
129
+ <<: *mysql
130
+ slave4:
131
+ database: octopus_shard_5
132
+ <<: *mysql
133
+
134
+ octopus_rails:
135
+ replicated: true
136
+ environments:
137
+ - staging
138
+ - production
139
+
140
+ staging:
141
+ slave1:
142
+ database: octopus_shard_2
143
+ <<: *mysql
144
+ slave2:
145
+ database: octopus_shard_3
146
+ <<: *mysql
147
+
148
+ production:
149
+ slave3:
150
+ database: octopus_shard_4
151
+ <<: *mysql
152
+ slave4:
153
+ database: octopus_shard_5
154
+ <<: *mysql
155
+
156
+ not_entire_sharded:
157
+ entire_sharded: false
158
+ shards:
159
+ europe:
160
+ database: octopus_shard_2
161
+ <<: *mysql
162
+ canada:
163
+ database: octopus_shard_3
164
+ <<: *mysql
165
+ brazil:
166
+ database: octopus_shard_4
167
+ <<: *mysql
168
+ russia:
169
+ database: octopus_shard_5
170
+ <<: *mysql
171
+
172
+ sharded_replicated_slave_grouped:
173
+ replicated: true
174
+ fully_replicated: true
175
+ shards:
176
+ russia:
177
+ database: octopus_shard_1
178
+ <<: *mysql
179
+ slaves1:
180
+ russia_slave11:
181
+ database: octopus_shard_1
182
+ <<: *mysql
183
+ russia_slave21:
184
+ database: octopus_shard_2
185
+ <<: *mysql
186
+ slaves2:
187
+ russia_slave21:
188
+ database: octopus_shard_3
189
+ <<: *mysql
190
+ russia_slave22:
191
+ database: octopus_shard_1
192
+ <<: *mysql
193
+ europe:
194
+ database: octopus_shard_2
195
+ <<: *mysql
196
+ slaves1:
197
+ europe_slave11:
198
+ database: octopus_shard_3
199
+ <<: *mysql
200
+ slaves2:
201
+ europe_slave21:
202
+ database: octopus_shard_1
203
+ <<: *mysql
204
+
205
+ replicated_slave_grouped:
206
+ replicated: true
207
+ fully_replicated: true
208
+ shards:
209
+ slaves1:
210
+ slave11:
211
+ database: octopus_shard_2
212
+ <<: *mysql
213
+ slaves2:
214
+ slave21:
215
+ database: octopus_shard_1
216
+ <<: *mysql
217
+ slaves3:
218
+ slave31:
219
+ database: octopus_shard_1
220
+ <<: *mysql
221
+ slave32:
222
+ database: octopus_shard_2
223
+ <<: *mysql
224
+
225
+ modify_config:
226
+ replicated: true
227
+ shards:
228
+ modify_config_read:
229
+ adapter: modify_config
230
+ database: octopus_shard_1
231
+ host: localhost
@@ -0,0 +1,9 @@
1
+ class CreateUsersUsingReplication < BaseOctopusMigrationClass
2
+ def self.up
3
+ Cat.create!(:name => 'Replication')
4
+ end
5
+
6
+ def self.down
7
+ Cat.delete_all
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class AddFieldInAllSlaves < BaseOctopusMigrationClass
2
+ using(:slave1, :slave2, :slave3, :slave4)
3
+
4
+ def self.up
5
+ Cat.create!(:name => 'Slaves')
6
+ end
7
+
8
+ def self.down
9
+ Cat.delete_all
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ class CreateUsersUsingBlock < BaseOctopusMigrationClass
2
+ def self.up
3
+ Octopus.using(:brazil) do
4
+ User.create!(:name => 'UsingBlock1')
5
+ User.create!(:name => 'UsingBlock2')
6
+ end
7
+
8
+ Octopus.using(:canada) do
9
+ User.create!(:name => 'UsingCanada')
10
+ User.create!(:name => 'UsingCanada2')
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ Octopus.using(:brazil) do
16
+ User.delete_all
17
+ end
18
+
19
+ Octopus.using(:canada) do
20
+ User.delete_all
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ class CreateUsersUsingBlockAndUsing < BaseOctopusMigrationClass
2
+ using(:brazil)
3
+
4
+ def self.up
5
+ Octopus.using(:canada) do
6
+ User.create!(:name => 'Canada')
7
+ end
8
+
9
+ User.create!(:name => 'Brazil')
10
+ end
11
+
12
+ def self.down
13
+ User.delete_all
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUsersOnShardsOfAGroupWithVersions < BaseOctopusMigrationClass
2
+ using_group(:country_shards)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Group')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUserOnShardsOfDefaultGroupWithVersions < BaseOctopusMigrationClass
2
+ def self.up
3
+ User.create!(:name => 'Default Group')
4
+ end
5
+
6
+ def self.down
7
+ User.delete_all
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUsersOnMaster < BaseOctopusMigrationClass
2
+ def self.up
3
+ User.create!(:name => 'Master')
4
+ end
5
+
6
+ def self.down
7
+ User.delete_all
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUsersOnCanada < BaseOctopusMigrationClass
2
+ using(:canada)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Sharding')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUsersOnBothShards < BaseOctopusMigrationClass
2
+ using(:brazil, :canada)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Both')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUsersOnShardsOfAGroup < BaseOctopusMigrationClass
2
+ using_group(:country_shards)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Group')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateUsersOnMultiplesGroups < BaseOctopusMigrationClass
2
+ using_group('country_shards', 'history_shards')
3
+
4
+ def self.up
5
+ User.create!(:name => 'MultipleGroup')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class RaiseExceptionWithInvalidShardName < BaseOctopusMigrationClass
2
+ using(:amazing_shard)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Error')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class RaiseExceptionWithInvalidMultipleShardNames < BaseOctopusMigrationClass
2
+ using(:brazil, :invalid_shard)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Error')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class RaiseExceptionWithInvalidGroupName < BaseOctopusMigrationClass
2
+ using_group(:invalid_group)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Error')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class RaiseExceptionWithMultipleInvalidGroupNames < BaseOctopusMigrationClass
2
+ using_group(:country_shards, :invalid_group)
3
+
4
+ def self.up
5
+ User.create!(:name => 'Error')
6
+ end
7
+
8
+ def self.down
9
+ User.delete_all
10
+ end
11
+ end