schema_plus_indexes 0.2.0 → 0.2.1
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 +4 -4
- data/README.md +4 -0
- data/gemfiles/activerecord-4.2/Gemfile.base +1 -1
- data/gemfiles/activerecord-4.2/Gemfile.mysql2 +2 -2
- data/lib/schema_plus/indexes/middleware/dumper.rb +7 -8
- data/lib/schema_plus/indexes/version.rb +1 -1
- data/schema_plus_indexes.gemspec +2 -2
- data/spec/schema_dumper_spec.rb +4 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3121eeeae9f409e4f1d0c4a379e39de02a8806a0
|
4
|
+
data.tar.gz: f2ce9696d738ba265d3277bd8d8ca13bd379a981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2edcfebaa5b39ab374348071042afe30773e3338f35669f7075cc472ac8b1788071140650c241d6b3423b10fd933cda245878ecc8c24bd27eb1317f71428165
|
7
|
+
data.tar.gz: d4713ba88555e4ee3982adf7cc5bed6e1e88c479b0efc8c642d0b82b88692f6865e7a19b866ad790569b4ee45d85c479f8af68c714a5865e73114de15bc21838
|
data/README.md
CHANGED
@@ -12,12 +12,12 @@ module SchemaPlus::Indexes
|
|
12
12
|
|
13
13
|
# first check for a single-column index
|
14
14
|
if (index = env.table.indexes.find(&its.columns == [column.name]))
|
15
|
-
column.
|
15
|
+
column.options[:index] = index_options(env, column, index)
|
16
16
|
env.table.indexes.delete(index)
|
17
17
|
|
18
18
|
# then check for the first of a multi-column index
|
19
19
|
elsif (index = env.table.indexes.find(&its.columns.first == column.name))
|
20
|
-
column.
|
20
|
+
column.options[:index] = index_options(env, column, index)
|
21
21
|
env.table.indexes.delete(index)
|
22
22
|
end
|
23
23
|
|
@@ -25,12 +25,11 @@ module SchemaPlus::Indexes
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
"index: {#{parts.join(', ')}}"
|
28
|
+
def index_options(env, column, index)
|
29
|
+
options = {}
|
30
|
+
options[:name] = index.name
|
31
|
+
options[:with] = (index.columns - [column.name]) if index.columns.length > 1
|
32
|
+
options.merge index.options
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
data/schema_plus_indexes.gemspec
CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency "activerecord", "~> 4.2"
|
21
|
-
gem.add_dependency "schema_plus_core", "~> 0
|
21
|
+
gem.add_dependency "schema_plus_core", "~> 1.0"
|
22
22
|
|
23
23
|
gem.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
gem.add_development_dependency "rake", "~> 10.0"
|
25
25
|
gem.add_development_dependency "rspec", "~> 3.0.0"
|
26
|
-
gem.add_development_dependency "schema_dev", "~> 3.
|
26
|
+
gem.add_development_dependency "schema_dev", "~> 3.6"
|
27
27
|
gem.add_development_dependency "simplecov"
|
28
28
|
gem.add_development_dependency "simplecov-gem-profile"
|
29
29
|
end
|
data/spec/schema_dumper_spec.rb
CHANGED
@@ -43,7 +43,7 @@ describe "Schema dump" do
|
|
43
43
|
|
44
44
|
it "should include in-table index definition" do
|
45
45
|
with_index Post, :user_id do
|
46
|
-
expect(dump_posts).to match(/"user_id"
|
46
|
+
expect(dump_posts).to match(/"user_id",.*:index=>/)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -55,19 +55,19 @@ describe "Schema dump" do
|
|
55
55
|
|
56
56
|
it "should include index name" do
|
57
57
|
with_index Post, :user_id, :name => "custom_name" do
|
58
|
-
expect(dump_posts).to match(/"user_id"
|
58
|
+
expect(dump_posts).to match(/"user_id",.*:index=>.*:name=>"custom_name"/)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should define unique index" do
|
63
63
|
with_index Post, :user_id, :name => "posts_user_id_index", :unique => true do
|
64
|
-
expect(dump_posts).to match(/"user_id"
|
64
|
+
expect(dump_posts).to match(/"user_id",.*:index=>.*:name=>"posts_user_id_index", :unique=>true/)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should include index order", :mysql => :skip do
|
69
69
|
with_index Post, [:user_id, :first_comment_id, :short_id], :order => { :user_id => :asc, :first_comment_id => :desc } do
|
70
|
-
expect(dump_posts).to match(/"user_id"
|
70
|
+
expect(dump_posts).to match(/"user_id".*:index=>{.*:with=>\["first_comment_id", "short_id"\],.*:order=>{"user_id"=>:asc, "first_comment_id"=>:desc, "short_id"=>:asc}/)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_indexes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|