mysql_double_index 0.1.2 → 0.1.3
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/lib/mysql_double_index.rb +10 -5
- data/lib/mysql_double_index/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfb6dcc0d17b8330f2f7b23714c636e5881f0e06
|
4
|
+
data.tar.gz: 0dd7f16d95d80c67eec39c0b4493edb3f2e93002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a989de740c4fdd616a0cb13deb9c2094cfdcd939a2ae881b93651b1bf16d0929e9f97630fdba0effa08ebe334d234f70c4350bffaf3b2625d457c2ef7be31d4
|
7
|
+
data.tar.gz: 9809c7d374cff111a676a8df4ff9f72cba534369d0a97f8d40f8bdd27d9163c038b00093a8b17523297c4ffb9aa2c1841b3c6e79f9018d584060a0e2b8b2ba18
|
data/lib/mysql_double_index.rb
CHANGED
@@ -10,14 +10,19 @@ module MysqlDoubleIndex
|
|
10
10
|
def test
|
11
11
|
end
|
12
12
|
|
13
|
-
def db_double_index
|
13
|
+
def db_double_index(table = nil)
|
14
14
|
begin
|
15
15
|
MysqlDoubleIndex.db_connection #连接数据库
|
16
16
|
result = {}
|
17
17
|
double_index = []
|
18
18
|
redundancy_index = []
|
19
|
-
|
20
|
-
|
19
|
+
if table.nil?
|
20
|
+
sql="show tables"
|
21
|
+
tables=ActiveRecord::Base.connection.execute(sql)
|
22
|
+
else
|
23
|
+
tables = []
|
24
|
+
tables << [table]
|
25
|
+
end
|
21
26
|
tables.each do |item|
|
22
27
|
tmp_hash = {}
|
23
28
|
keys = ActiveRecord::Base.connection.execute("show index from #{item[0]}")
|
@@ -56,14 +61,14 @@ module MysqlDoubleIndex
|
|
56
61
|
print_arr << [item]
|
57
62
|
end
|
58
63
|
table = Terminal::Table.new :rows => print_arr
|
59
|
-
puts table
|
64
|
+
puts table if double_index.size > 0
|
60
65
|
print_arr = []
|
61
66
|
print_arr << ["冗余索引"]
|
62
67
|
redundancy_index.each do |item|
|
63
68
|
print_arr << [item]
|
64
69
|
end
|
65
70
|
table = Terminal::Table.new :rows => print_arr
|
66
|
-
puts table
|
71
|
+
puts table if redundancy_index.size > 0
|
67
72
|
rescue Exception => e
|
68
73
|
puts e.backtrace
|
69
74
|
ensure
|