gravis-acts_as_archive 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_archive/base/table.rb +18 -6
- data/require.rb +1 -1
- metadata +4 -4
@@ -43,7 +43,7 @@ module ActsAsArchive
|
|
43
43
|
indexes = archive_table_indexed_columns
|
44
44
|
|
45
45
|
(archive_indexes - indexes).each do |index|
|
46
|
-
connection.add_index("archived_#{table_name}", index
|
46
|
+
connection.add_index("archived_#{table_name}", index) if table_has_columns(index)
|
47
47
|
end
|
48
48
|
(indexes - archive_indexes).each do |index|
|
49
49
|
connection.remove_index("archived_#{table_name}", index) if table_has_columns(index)
|
@@ -66,14 +66,26 @@ module ActsAsArchive
|
|
66
66
|
|
67
67
|
private
|
68
68
|
|
69
|
+
# def archive_table_indexed_columns
|
70
|
+
# case connection.class.to_s
|
71
|
+
# when "ActiveRecord::ConnectionAdapters::MysqlAdapter"
|
72
|
+
# index_query = "SHOW INDEX FROM archived_#{table_name}"
|
73
|
+
# indexes = connection.select_all(index_query).collect do |r|
|
74
|
+
# r["Column_name"]
|
75
|
+
# end
|
76
|
+
# when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter"
|
77
|
+
# index_query = "SELECT indexname FROM pg_indexes WHERE tablename = '#{table_name}'"
|
78
|
+
# indexes = connection.select_all(index_query).collect do |r|
|
79
|
+
# r["indexname"].split("_on_").last.split("_and_")
|
80
|
+
# end
|
81
|
+
# else
|
82
|
+
# raise "Unsupported Database"
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
|
69
86
|
def table_has_columns(columns)
|
70
|
-
self::Archive.reset_column_information
|
71
87
|
!Array(columns).select {|current_column| self::Archive.column_names.include?(current_column.to_s)}.empty?
|
72
88
|
end
|
73
|
-
|
74
|
-
def index_name_for(table_name, index)
|
75
|
-
"index_by_#{Array(index).join("_and_")}".to_sym if "index_archived_#{table_name}_on_#{Array(index).join("_and_")}".length > 63
|
76
|
-
end
|
77
89
|
end
|
78
90
|
|
79
91
|
module InstanceMethods
|
data/require.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gravis-acts_as_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 8
|
10
|
+
version: 0.2.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|
@@ -16,7 +16,7 @@ bindir: bin
|
|
16
16
|
cert_chain: []
|
17
17
|
|
18
18
|
date: 2010-05-31 00:00:00 +02:00
|
19
|
-
default_executable:
|
19
|
+
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: require
|