shameless 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/shameless/configuration.rb +2 -1
- data/lib/shameless/index.rb +2 -2
- data/lib/shameless/model.rb +25 -18
- data/lib/shameless/store.rb +2 -1
- data/lib/shameless/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ff6ea520714793fdb051f127d2e4cbbf931fb29
|
4
|
+
data.tar.gz: 41128cd58c21dd895fc7323777693e2a06ac3843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ecbebf884feae9a8beb027c3e3b1c6f567b29f897e5b71902190c01f42628de9b504368b59890d5f5d06ad52c73096b6f01260ffba56860dfb4ef0c6b8ab9f
|
7
|
+
data.tar.gz: 5185109b6ab8aadef0f441d0ae6b56892d19910973dcd11456c66c8c93bd257dd58b501d7c890d3595520db155aec186331e7935e1342a093c770a507a4af2fd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### Unreleased
|
2
|
+
|
3
|
+
### 0.4.0 (2016-11-21)
|
4
|
+
|
5
|
+
* `Model#reload` now reloads all cells
|
6
|
+
* Add `Model#cells`
|
7
|
+
* Add `Configuration#create_table_options`
|
8
|
+
* Include shard in underlying index name
|
9
|
+
|
1
10
|
### 0.3.1 (2016-11-18)
|
2
11
|
|
3
12
|
* Use more static names for underlying database indices
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Shameless
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :partition_urls, :shards_count, :connection_options, :database_extensions
|
3
|
+
attr_accessor :partition_urls, :shards_count, :connection_options, :database_extensions,
|
4
|
+
:create_table_options
|
4
5
|
|
5
6
|
attr_accessor :legacy_created_at_is_bigint
|
6
7
|
|
data/lib/shameless/index.rb
CHANGED
@@ -61,14 +61,14 @@ module Shameless
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def create_tables!
|
64
|
-
@model.store.create_table!(table_name) do |t|
|
64
|
+
@model.store.create_table!(table_name) do |t, sharded_table_name|
|
65
65
|
@columns.each do |name, type|
|
66
66
|
t.column name, type, null: false
|
67
67
|
end
|
68
68
|
|
69
69
|
t.varchar :uuid, size: 36
|
70
70
|
|
71
|
-
t.index @columns.keys, name: "#{
|
71
|
+
t.index @columns.keys, name: "#{sharded_table_name}_index", unique: true
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
data/lib/shameless/model.rb
CHANGED
@@ -24,7 +24,6 @@ module Shameless
|
|
24
24
|
name = name.to_s
|
25
25
|
|
26
26
|
define_method(name) do
|
27
|
-
@cells ||= {}
|
28
27
|
@cells[name] ||= Cell.new(self, name)
|
29
28
|
end
|
30
29
|
end
|
@@ -75,7 +74,7 @@ module Shameless
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def create_tables!
|
78
|
-
@store.create_table!(table_name) do |t|
|
77
|
+
@store.create_table!(table_name) do |t, sharded_table_name|
|
79
78
|
t.primary_key :id
|
80
79
|
t.varchar :uuid, size: 36
|
81
80
|
t.varchar :column_name, null: false
|
@@ -85,7 +84,7 @@ module Shameless
|
|
85
84
|
created_at_type = @store.configuration.legacy_created_at_is_bigint ? :bigint : :datetime
|
86
85
|
t.column :created_at, created_at_type, null: false
|
87
86
|
|
88
|
-
t.index %i[uuid column_name ref_key], name: "#{
|
87
|
+
t.index %i[uuid column_name ref_key], name: "#{sharded_table_name}_model", unique: true
|
89
88
|
end
|
90
89
|
|
91
90
|
@indices.each(&:create_tables!)
|
@@ -106,51 +105,59 @@ module Shameless
|
|
106
105
|
private
|
107
106
|
|
108
107
|
module InstanceMethods
|
109
|
-
attr_reader :uuid
|
108
|
+
attr_reader :uuid
|
110
109
|
|
111
110
|
def initialize(uuid, base_body = nil)
|
112
111
|
@uuid = uuid
|
113
|
-
@
|
112
|
+
@cells = {Cell::BASE => Cell.base(self, base_body)}
|
113
|
+
end
|
114
|
+
|
115
|
+
def base
|
116
|
+
@cells[Cell::BASE]
|
114
117
|
end
|
115
118
|
|
116
119
|
def [](field)
|
117
|
-
|
120
|
+
base[field]
|
118
121
|
end
|
119
122
|
|
120
123
|
def []=(field, value)
|
121
|
-
|
124
|
+
base[field] = value
|
122
125
|
end
|
123
126
|
|
124
127
|
def update(values)
|
125
|
-
|
128
|
+
base.update(values)
|
126
129
|
end
|
127
130
|
|
128
131
|
def save
|
129
|
-
|
132
|
+
base.save
|
130
133
|
end
|
131
134
|
|
132
135
|
def ref_key
|
133
|
-
|
136
|
+
base.ref_key
|
134
137
|
end
|
135
138
|
|
136
139
|
def created_at
|
137
|
-
|
140
|
+
base.created_at
|
138
141
|
end
|
139
142
|
|
140
143
|
def previous
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
def reload
|
145
|
-
@base.reload
|
144
|
+
base.previous
|
146
145
|
end
|
147
146
|
|
148
147
|
def fetch(key, default)
|
149
|
-
|
148
|
+
base.fetch(key, default)
|
150
149
|
end
|
151
150
|
|
152
151
|
def present?
|
153
|
-
|
152
|
+
base.present?
|
153
|
+
end
|
154
|
+
|
155
|
+
def reload
|
156
|
+
cells.each(&:reload)
|
157
|
+
end
|
158
|
+
|
159
|
+
def cells
|
160
|
+
@cells.values
|
154
161
|
end
|
155
162
|
|
156
163
|
def put_cell(cell_values)
|
data/lib/shameless/store.rb
CHANGED
@@ -46,7 +46,8 @@ module Shameless
|
|
46
46
|
each_shard do |shard|
|
47
47
|
partition = find_partition_for_shard(shard)
|
48
48
|
sharded_table_name = table_name_with_shard(table_name, shard)
|
49
|
-
|
49
|
+
options = @configuration.create_table_options || {}
|
50
|
+
partition.create_table(sharded_table_name, options) { block.call(self, sharded_table_name) }
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
data/lib/shameless/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shameless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olek Janiszewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|