-
Notifications
You must be signed in to change notification settings - Fork 900
/
Copy pathar_base.rb
36 lines (31 loc) · 964 Bytes
/
ar_base.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module ActiveRecord
class Base
include Vmdb::Logging
# Truncates the table.
#
# ==== Example
#
# Post.truncate
def self.truncate
connection.truncate(table_name, "#{name} Truncate")
end
def self.reindex
_log.info("Reindexing table #{reindex_table_name}")
result = connection.reindex_table(reindex_table_name)
_log.info("Completed Reindexing of table #{reindex_table_name} with result #{result.result_status}")
end
def self.reindex_table_name
table_name
end
def self.vacuum
_log.info("Vacuuming table #{table_name}")
result = connection.vacuum_analyze_table(table_name)
_log.info("Completed Vacuuming of table #{table_name} with result #{result.result_status}")
end
def self.connectable?
connection && connected?
rescue ActiveRecord::ConnectionNotEstablished, ActiveRecord::NoDatabaseError, PG::ConnectionBad
false
end
end
end