lol_dba 1.6.7 → 2.0.0
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/Gemfile +2 -1
- data/Gemfile.lock +19 -18
- data/README.md +1 -1
- data/gemfiles/rails_3_2.gemfile +2 -1
- data/gemfiles/rails_3_2.gemfile.lock +3 -3
- data/gemfiles/rails_4_0.gemfile +2 -1
- data/gemfiles/rails_4_0.gemfile.lock +3 -3
- data/gemfiles/rails_4_1.gemfile +2 -1
- data/gemfiles/rails_4_1.gemfile.lock +3 -3
- data/gemfiles/rails_4_2.gemfile +2 -1
- data/gemfiles/rails_4_2.gemfile.lock +3 -3
- data/lib/lol_dba.rb +22 -20
- data/lib/lol_dba/version.rb +1 -1
- data/lol_dba.gemspec +0 -1
- data/spec/spec_helper.rb +2 -0
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba7fdc2c7953969c50ccd82353b9e9162b6e21c
|
4
|
+
data.tar.gz: 4e15e8ce2c0c07dd96a8cbd29a6eac62b06fe117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05dbb7d70f02e178a53a28014b3bd0ca56be77bde892512e8b6f4e124e4c25853548f44bbb4a531a7c1545d69c7925c9986b67ef3b881d547a056bbfa020afc
|
7
|
+
data.tar.gz: 0b005f850e1dc737e699c9052591c0a4e54454a3cda1deac9680e79f94384f332c2ff4ad271726e6721001e0ad4bfc1eeaff0908507b54f0946b78c891a2c840
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lol_dba (1.6.
|
4
|
+
lol_dba (1.6.7)
|
5
5
|
actionpack (>= 3.0, < 5.0)
|
6
6
|
activerecord (>= 3.0, < 5.0)
|
7
7
|
railties (>= 3.0, < 5.0)
|
@@ -96,22 +96,23 @@ GEM
|
|
96
96
|
rake (>= 0.8.7)
|
97
97
|
thor (>= 0.18.1, < 2.0)
|
98
98
|
rake (10.4.2)
|
99
|
-
rspec-core (3.
|
100
|
-
rspec-support (~> 3.
|
101
|
-
rspec-expectations (3.0
|
99
|
+
rspec-core (3.2.2)
|
100
|
+
rspec-support (~> 3.2.0)
|
101
|
+
rspec-expectations (3.2.0)
|
102
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
-
rspec-support (~> 3.
|
104
|
-
rspec-mocks (3.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
rspec-
|
112
|
-
rspec-
|
113
|
-
rspec-
|
114
|
-
|
103
|
+
rspec-support (~> 3.2.0)
|
104
|
+
rspec-mocks (3.2.1)
|
105
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
+
rspec-support (~> 3.2.0)
|
107
|
+
rspec-rails (3.2.1)
|
108
|
+
actionpack (>= 3.0, < 4.3)
|
109
|
+
activesupport (>= 3.0, < 4.3)
|
110
|
+
railties (>= 3.0, < 4.3)
|
111
|
+
rspec-core (~> 3.2.0)
|
112
|
+
rspec-expectations (~> 3.2.0)
|
113
|
+
rspec-mocks (~> 3.2.0)
|
114
|
+
rspec-support (~> 3.2.0)
|
115
|
+
rspec-support (3.2.2)
|
115
116
|
sprockets (2.12.3)
|
116
117
|
hike (~> 1.2)
|
117
118
|
multi_json (~> 1.0)
|
@@ -137,6 +138,6 @@ DEPENDENCIES
|
|
137
138
|
appraisal (~> 1.0)
|
138
139
|
lol_dba!
|
139
140
|
rails
|
140
|
-
rspec-rails
|
141
|
+
rspec-rails
|
141
142
|
sqlite3
|
142
|
-
test-unit
|
143
|
+
test-unit
|
data/README.md
CHANGED
data/gemfiles/rails_3_2.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
lol_dba (1.6.
|
4
|
+
lol_dba (1.6.7)
|
5
5
|
actionpack (>= 3.0, < 5.0)
|
6
6
|
activerecord (>= 3.0, < 5.0)
|
7
7
|
railties (>= 3.0, < 5.0)
|
@@ -121,6 +121,6 @@ DEPENDENCIES
|
|
121
121
|
lol_dba!
|
122
122
|
rails
|
123
123
|
railties (~> 3.2.21)
|
124
|
-
rspec-rails
|
124
|
+
rspec-rails
|
125
125
|
sqlite3
|
126
|
-
test-unit
|
126
|
+
test-unit
|
data/gemfiles/rails_4_0.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
lol_dba (1.6.
|
4
|
+
lol_dba (1.6.7)
|
5
5
|
actionpack (>= 3.0, < 5.0)
|
6
6
|
activerecord (>= 3.0, < 5.0)
|
7
7
|
railties (>= 3.0, < 5.0)
|
@@ -109,6 +109,6 @@ DEPENDENCIES
|
|
109
109
|
lol_dba!
|
110
110
|
rails
|
111
111
|
railties (~> 4.0.13)
|
112
|
-
rspec-rails
|
112
|
+
rspec-rails
|
113
113
|
sqlite3
|
114
|
-
test-unit
|
114
|
+
test-unit
|
data/gemfiles/rails_4_1.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
lol_dba (1.6.
|
4
|
+
lol_dba (1.6.7)
|
5
5
|
actionpack (>= 3.0, < 5.0)
|
6
6
|
activerecord (>= 3.0, < 5.0)
|
7
7
|
railties (>= 3.0, < 5.0)
|
@@ -115,6 +115,6 @@ DEPENDENCIES
|
|
115
115
|
lol_dba!
|
116
116
|
rails
|
117
117
|
railties (~> 4.1.9)
|
118
|
-
rspec-rails
|
118
|
+
rspec-rails
|
119
119
|
sqlite3
|
120
|
-
test-unit
|
120
|
+
test-unit
|
data/gemfiles/rails_4_2.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
lol_dba (1.6.
|
4
|
+
lol_dba (1.6.7)
|
5
5
|
actionpack (>= 3.0, < 5.0)
|
6
6
|
activerecord (>= 3.0, < 5.0)
|
7
7
|
railties (>= 3.0, < 5.0)
|
@@ -140,6 +140,6 @@ DEPENDENCIES
|
|
140
140
|
lol_dba!
|
141
141
|
rails
|
142
142
|
railties (~> 4.2.0)
|
143
|
-
rspec-rails
|
143
|
+
rspec-rails
|
144
144
|
sqlite3
|
145
|
-
test-unit
|
145
|
+
test-unit
|
data/lib/lol_dba.rb
CHANGED
@@ -18,10 +18,10 @@ EOM
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.get_through_foreign_key(target_class, reflection_options)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# has_many :through
|
22
|
+
reflection = target_class.reflections[reflection_options.options[:through].to_s]
|
23
|
+
|
24
|
+
unless reflection
|
25
25
|
# has_and_belongs_to_many
|
26
26
|
reflection = reflection_options
|
27
27
|
end
|
@@ -85,22 +85,25 @@ EOM
|
|
85
85
|
|
86
86
|
model_classes.each do |class_name|
|
87
87
|
unless class_name.descends_from_active_record?
|
88
|
-
|
88
|
+
index_name = [class_name.inheritance_column, class_name.base_class.primary_key].sort
|
89
|
+
@index_migrations[class_name.base_class.table_name] += [index_name]
|
89
90
|
end
|
90
|
-
class_name.reflections.
|
91
|
+
reflections = class_name.reflections.stringify_keys
|
92
|
+
reflections.each_pair do |reflection_name, reflection_options|
|
91
93
|
begin
|
94
|
+
index_name = ""
|
92
95
|
case reflection_options.macro
|
93
96
|
when :belongs_to
|
94
97
|
# polymorphic?
|
95
|
-
|
96
|
-
if reflection_options.options
|
98
|
+
table_name = class_name.table_name
|
99
|
+
if reflection_options.options[:polymorphic]
|
97
100
|
poly_type = "#{reflection_options.name.to_s}_type"
|
98
101
|
poly_id = "#{reflection_options.name.to_s}_id"
|
99
102
|
|
100
|
-
|
103
|
+
index_name = [[poly_type, poly_id].sort]
|
101
104
|
else
|
102
105
|
foreign_key = reflection_options.options[:foreign_key] ||= reflection_options.respond_to?(:primary_key_name) ? reflection_options.primary_key_name : reflection_options.foreign_key
|
103
|
-
|
106
|
+
index_name = foreign_key.to_s
|
104
107
|
end
|
105
108
|
when :has_and_belongs_to_many
|
106
109
|
table_name = reflection_options.options[:join_table] ||= [class_name.table_name, reflection_name.to_s].sort.join('_')
|
@@ -109,12 +112,11 @@ EOM
|
|
109
112
|
|
110
113
|
foreign_key = get_through_foreign_key(class_name, reflection_options)
|
111
114
|
|
112
|
-
|
113
|
-
@index_migrations[table_name.to_s] += [composite_keys] unless @index_migrations[table_name].include?(composite_keys)
|
115
|
+
index_name = [association_foreign_key, foreign_key].sort
|
114
116
|
when :has_many
|
115
117
|
# has_many tables are threaten by the other side of the relation
|
116
118
|
next unless reflection_options.options[:through]
|
117
|
-
through_class =
|
119
|
+
through_class = reflections[reflection_options.options[:through].to_s].klass
|
118
120
|
table_name = through_class.table_name
|
119
121
|
|
120
122
|
foreign_key = get_through_foreign_key(class_name, reflection_options)
|
@@ -124,18 +126,18 @@ EOM
|
|
124
126
|
association_foreign_key = get_through_foreign_key(association_class, reflection_options)
|
125
127
|
else
|
126
128
|
# go to joining model through has_many and find belongs_to
|
127
|
-
|
128
|
-
blg_to_class = blg_to_reflection.class_name.constantize
|
129
|
-
|
130
|
-
# get foreign_key from belongs_to
|
131
|
-
association_foreign_key = blg_to_class.reflections.stringify_keys[reflection_name.to_s.singularize.to_s].options[:foreign_key]
|
129
|
+
association_foreign_key = through_class.reflections.stringify_keys[reflection_name.singularize].options[:foreign_key]
|
132
130
|
end
|
133
131
|
|
134
132
|
#FIXME currently we don't support :through => :another_regular_has_many_and_non_through_relation
|
135
133
|
next if association_foreign_key.nil?
|
136
|
-
|
137
|
-
@index_migrations[table_name] += [composite_keys] unless @index_migrations[table_name].include?(composite_keys)
|
134
|
+
index_name = [association_foreign_key.to_s, foreign_key.to_s].sort
|
138
135
|
end
|
136
|
+
|
137
|
+
unless index_name == "" || reflection_options.options.include?(:class)
|
138
|
+
@index_migrations[table_name] += [index_name]
|
139
|
+
end
|
140
|
+
|
139
141
|
rescue Exception => e
|
140
142
|
puts "Some errors here:"
|
141
143
|
puts "Please, create an issue with the following information here https://github.com/plentz/lol_dba/issues:"
|
data/lib/lol_dba/version.rb
CHANGED
data/lol_dba.gemspec
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lol_dba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Plentz
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activerecord
|
@@ -88,20 +88,6 @@ dependencies:
|
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '1.0'
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: test-unit
|
93
|
-
requirement: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '3.0'
|
98
|
-
type: :development
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - "~>"
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: '3.0'
|
105
91
|
description: lol_dba is a small package of rake tasks that scan your application models
|
106
92
|
and displays a list of columns that probably should be indexed. Also, it can generate
|
107
93
|
.sql migration scripts.
|