schema_plus_pg_indexes 0.1.12 → 0.2.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 +2 -2
- data/README.md +2 -1
- data/gemfiles/{activerecord-4.2 → activerecord-5.0}/Gemfile.base +1 -1
- data/gemfiles/{activerecord-4.2 → activerecord-5.0}/Gemfile.postgresql +0 -0
- data/lib/schema_plus_pg_indexes/middleware/postgresql/dumper.rb +14 -23
- data/lib/schema_plus_pg_indexes/middleware/postgresql/schema.rb +9 -9
- data/lib/schema_plus_pg_indexes/version.rb +1 -1
- data/schema_dev.yml +2 -2
- data/schema_plus_pg_indexes.gemspec +3 -3
- data/spec/schema_dumper_spec.rb +5 -5
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32103d4c7753e4551e51ed658016996e2cdc180
|
4
|
+
data.tar.gz: edf9dddc470db8759c183b18d33df4f649dc32f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e304b33918637897b17bb7518f6d962849ed17a2a1606a994a7159c3d9f4a1489abbb8f1d174660c896f3f4f44cfe0083f8480f74cab6b925062e14ae1f0e7a
|
7
|
+
data.tar.gz: 774d15bd7fce97f4d39926310c36457861bb44533219b19a9a5f936e8eca9d40e00ded2e9b871971c2fe0209e7271c8eaacdc9f29905e903a9d5d80f0ade2299
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -55,12 +55,13 @@ schema_plus_pg_indexes is tested on
|
|
55
55
|
|
56
56
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
57
57
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
58
|
-
* ruby **2.1
|
58
|
+
* ruby **2.3.1** with activerecord **5.0**, using **postgresql**
|
59
59
|
|
60
60
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
61
61
|
|
62
62
|
## History
|
63
63
|
|
64
|
+
* v0.2.0 - Support Rails 5 (Removed Rails 4.2 support)
|
64
65
|
* v0.1.12 - Missing require
|
65
66
|
* v0.1.11 - Explicit gem dependencies
|
66
67
|
* v0.1.10 - Upgrade to schmea_plus_core 1.0
|
File without changes
|
@@ -2,44 +2,35 @@ module SchemaPlusPgIndexes
|
|
2
2
|
module Middleware
|
3
3
|
module Postgresql
|
4
4
|
module Dumper
|
5
|
-
|
6
|
-
module Indexes
|
5
|
+
module Table
|
7
6
|
|
8
7
|
# Dump index extensions
|
9
8
|
def after(env)
|
10
|
-
index_defs =
|
9
|
+
index_defs = env.connection.indexes(env.table.name)
|
11
10
|
|
12
|
-
|
13
|
-
index_def = index_defs.find(&its.name ==
|
14
|
-
|
15
|
-
|
11
|
+
def set_index_options(name, options, index_defs)
|
12
|
+
index_def = index_defs.find(&its.name == name)
|
13
|
+
options[:case_sensitive] = false unless index_def.case_sensitive?
|
14
|
+
options[:expression] = index_def.expression if index_def.expression and index_def.case_sensitive?
|
16
15
|
unless index_def.operator_classes.blank?
|
17
16
|
if index_def.columns.uniq.length <= 1 && index_def.operator_classes.values.uniq.length == 1
|
18
|
-
|
17
|
+
options[:operator_class] = index_def.operator_classes.values.first
|
19
18
|
else
|
20
|
-
|
19
|
+
options[:operator_class] = index_def.operator_classes
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
24
|
-
end
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
index_defs = Dumper.get_index_definitions(env, env.table)
|
24
|
+
env.table.columns.each do |column_dump|
|
25
|
+
index = column_dump.options[:index]
|
26
|
+
set_index_options(index[:name], index, index_defs) if index
|
27
|
+
end
|
32
28
|
|
33
|
-
env.table.indexes.
|
34
|
-
|
35
|
-
env.table.indexes.delete(index)
|
29
|
+
env.table.indexes.each do |index_dump|
|
30
|
+
set_index_options(index_dump.name, index_dump.options, index_defs)
|
36
31
|
end
|
37
32
|
end
|
38
|
-
end
|
39
33
|
|
40
|
-
def self.get_index_definitions(env, table_dump)
|
41
|
-
env.dump.data.index_definitions ||= {}
|
42
|
-
env.dump.data.index_definitions[table_dump.name] ||= env.connection.indexes(table_dump.name)
|
43
34
|
end
|
44
35
|
end
|
45
36
|
end
|
@@ -53,7 +53,7 @@ module SchemaPlusPgIndexes
|
|
53
53
|
|
54
54
|
env.index_definitions += result.map do |(index_name, unique, indkey, inddef, oid, using, conditions, expression, indclass)|
|
55
55
|
index_keys = indkey.split(" ")
|
56
|
-
opclasses = indclass.split(" ")
|
56
|
+
opclasses = indclass.split(" ").map(&:to_i)
|
57
57
|
|
58
58
|
rows = env.connection.query(<<-SQL, 'SCHEMA')
|
59
59
|
SELECT CAST(a.attnum as VARCHAR), a.attname, t.typname
|
@@ -98,14 +98,14 @@ module SchemaPlusPgIndexes
|
|
98
98
|
orders = desc_order_columns.any? ? Hash[column_names.map {|column| [column, desc_order_columns.include?(column) ? :desc : :asc]}] : {}
|
99
99
|
|
100
100
|
::ActiveRecord::ConnectionAdapters::IndexDefinition.new(env.table_name, column_names,
|
101
|
-
:
|
102
|
-
:unique
|
103
|
-
:orders
|
104
|
-
:
|
105
|
-
:case_sensitive
|
106
|
-
:using
|
107
|
-
:
|
108
|
-
:expression
|
101
|
+
name: index_name,
|
102
|
+
unique: unique,
|
103
|
+
orders: orders,
|
104
|
+
where: conditions,
|
105
|
+
case_sensitive: case_sensitive,
|
106
|
+
using: using.downcase == "btree" ? nil : using.to_sym,
|
107
|
+
operator_classes: operator_classes,
|
108
|
+
expression: expression)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
data/schema_dev.yml
CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "activerecord", "~>
|
21
|
-
gem.add_dependency "schema_plus_indexes", "~> 0.
|
22
|
-
gem.add_dependency "schema_plus_core", "~>
|
20
|
+
gem.add_dependency "activerecord", "~> 5.0"
|
21
|
+
gem.add_dependency "schema_plus_indexes", "~> 0.2", ">= 0.2.4"
|
22
|
+
gem.add_dependency "schema_plus_core", "~> 2.0"
|
23
23
|
gem.add_dependency "its-it", "~> 1.2"
|
24
24
|
|
25
25
|
gem.add_development_dependency "bundler", "~> 1.7"
|
data/spec/schema_dumper_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe "Schema dump" do
|
|
54
54
|
|
55
55
|
it "should define index with type cast" do
|
56
56
|
with_index Post, [:integer_col], :name => "index_with_type_cast", :expression => "LOWER(integer_col::text)" do
|
57
|
-
expect(dump_posts).to include(%q{t.index :name=>"index_with_type_cast", :expression=>"lower((integer_col)::text)"})
|
57
|
+
expect(dump_posts).to include(%q{t.index [], :name=>"index_with_type_cast", :expression=>"lower((integer_col)::text)"})
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -82,7 +82,7 @@ describe "Schema dump" do
|
|
82
82
|
|
83
83
|
it "should define expression" do
|
84
84
|
with_index Post, :name => "posts_freaky_index", :expression => "USING hash (least(id, user_id))" do
|
85
|
-
expect(dump_posts).to include(%q{t.index :name=>"posts_freaky_index", :using=>:hash, :expression=>"LEAST(id, user_id)"})
|
85
|
+
expect(dump_posts).to include(%q{t.index [], :name=>"posts_freaky_index", :using=>:hash, :expression=>"LEAST(id, user_id)"})
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -101,7 +101,7 @@ describe "Schema dump" do
|
|
101
101
|
|
102
102
|
it "should define expression with operator_class" do
|
103
103
|
with_index Post, :name => "expr_with_opclass", :expression => "upper(str_short || string_no_default)", :operator_class => 'text_pattern_ops' do
|
104
|
-
expect(dump_posts).to include(%q{t.index :name=>"expr_with_opclass", :expression=>"upper(((str_short)::text || (string_no_default)::text))", :operator_class=>"text_pattern_ops"})
|
104
|
+
expect(dump_posts).to include(%q{t.index [], :name=>"expr_with_opclass", :expression=>"upper(((str_short)::text || (string_no_default)::text))", :operator_class=>"text_pattern_ops"})
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -126,14 +126,14 @@ describe "Schema dump" do
|
|
126
126
|
|
127
127
|
it "should dump unique: true with expression (Issue #142)" do
|
128
128
|
with_index Post, :name => "posts_user_body_index", :unique => true, :expression => "BTRIM(LOWER(body))" do
|
129
|
-
expect(dump_posts).to include(%q{t.index :name=>"posts_user_body_index", :unique=>true, :expression=>"btrim(lower(body))"})
|
129
|
+
expect(dump_posts).to include(%q{t.index [], :name=>"posts_user_body_index", :unique=>true, :expression=>"btrim(lower(body))"})
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
|
134
134
|
it "should not define :case_sensitive => false with non-trivial expression" do
|
135
135
|
with_index Post, :name => "posts_user_body_index", :expression => "BTRIM(LOWER(body))" do
|
136
|
-
expect(dump_posts).to include(%q{t.index :name=>"posts_user_body_index", :expression=>"btrim(lower(body))"})
|
136
|
+
expect(dump_posts).to include(%q{t.index [], :name=>"posts_user_body_index", :expression=>"btrim(lower(body))"})
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_pg_indexes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,48 +16,48 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: schema_plus_indexes
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.2'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.2.4
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
43
|
+
version: '0.2'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.2.4
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: schema_plus_core
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.0'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: its-it
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,8 +170,8 @@ files:
|
|
170
170
|
- README.md
|
171
171
|
- Rakefile
|
172
172
|
- gemfiles/Gemfile.base
|
173
|
-
- gemfiles/activerecord-
|
174
|
-
- gemfiles/activerecord-
|
173
|
+
- gemfiles/activerecord-5.0/Gemfile.base
|
174
|
+
- gemfiles/activerecord-5.0/Gemfile.postgresql
|
175
175
|
- lib/schema_plus_pg_indexes.rb
|
176
176
|
- lib/schema_plus_pg_indexes/active_record/connection_adapters/index_definition.rb
|
177
177
|
- lib/schema_plus_pg_indexes/active_record/connection_adapters/postgresql_adapter.rb
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
212
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.5.1
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Adds support in ActiveRecord for PostgreSQL index expressions and operator
|