sengiri 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e96f58180e38a69f58dabf28faa0722d4eca41b3
4
- data.tar.gz: 97123fb3ce73b761c46ac5127e06f619f3ab6e3a
3
+ metadata.gz: 0cf2b0a2d6136b98587fdc922d0af979bc5615dc
4
+ data.tar.gz: 11669c7daa1637126d51e6688d399bd4b9dc1e74
5
5
  SHA512:
6
- metadata.gz: c5992be99772ef05bd1a3ed049bbe72ed7a3ed1767f7b9d91562043be7c7f5ad6e484301cb03e37b717f775532fc6657a83187c9c0536011aa641920de550bf1
7
- data.tar.gz: 8a3449b6f80cecb874ea5ac8e7914313eac1f6184377af0af8c66a858dccd793eb51f3c11c7446a864003cb45d2a86190a4a03daeab77b9224ea244f425a56fe
6
+ metadata.gz: 13d32f1573dfa4cd9ca730a4c1007af735996f1290416dba0233b6ad1f67cbeee604e63a9b64bfa34adf169fdb4d0b0ace2f9a46610ad6ebc290b9ce80e6ff8e
7
+ data.tar.gz: 3bb32d54a802c7ba3f7d76cb5c7c16291af7969496322dffec9fed8935bf7d906cae272f11d8854e07536e7b1cf8dfbac4823b34c329a14594136493af6f5f25
data/README.md CHANGED
@@ -17,15 +17,15 @@ Flexible sharding access for Ruby on Rails with ActiveRecord
17
17
  password:
18
18
  host: localhost
19
19
 
20
- mygroup_1:
20
+ mygroup_shards_first: # define shard as 'first'
21
21
  <<: *mysql
22
22
  database: mygroup_1
23
23
  host: hosta
24
- mygroup_2:
24
+ mygroup_shards_second: # define shard as 'second'
25
25
  <<: *mysql
26
26
  database: mygroup_2
27
27
  host: hostb
28
- mygroup_3:
28
+ mygroup_shards_third: # define shard as 'third'
29
29
  <<: *mysql
30
30
  database: mygroup_3
31
31
  host: hostc
@@ -38,5 +38,39 @@ Flexible sharding access for Ruby on Rails with ActiveRecord
38
38
  rake sengiri:mygroup:db:create
39
39
  rake sengiri:mygroup:db:migrate
40
40
 
41
+
42
+ ## Sharding access
43
+
44
+ User.shard('second') do |shard|
45
+ shard.all.limit(10) # query on db 'mygroup_1'
46
+ end
47
+
48
+
49
+ User.shards do |shard|
50
+ shard.all.limit(10) # query on all db 'mygroup_1', 'mygroup_2', 'mygroup_3'
51
+ end
52
+
53
+ ## Transaction
54
+
55
+ User.shard('second').transaction do
56
+ # in mygroup_2 transaction
57
+ end
58
+
59
+
60
+ User.transaction do
61
+ # in mygroup_1, mygroup_2 and mygroup_3 transaction
62
+ end
63
+
64
+
65
+ # This is same as below
66
+
67
+
68
+ User.shard('first').transaction do
69
+ User.shard('second').transaction do
70
+ User.shard('third').transaction do
71
+ end
72
+ end
73
+ end
74
+
41
75
 
42
76
  This project rocks and uses MIT-LICENSE.
@@ -14,7 +14,6 @@ module Sengiri
14
14
  def create_migration_file
15
15
  set_local_assigns!
16
16
  validate_file_name!
17
- binding.pry
18
17
  migration_template @migration_template, "db/sengiri/#{self.group}/#{file_name}.rb"
19
18
  end
20
19
  end
@@ -1,5 +1,4 @@
1
1
  require 'active_record'
2
- require 'pry'
3
2
 
4
3
  shard = ENV['SHARD']
5
4
 
@@ -1,3 +1,3 @@
1
1
  module Sengiri
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sengiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mewlist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails