3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/time_travel/sql_function_helper.rb', line 3
def self.create(schema=nil)
connection = ActiveRecord::Base.connection
gem_root = File.expand_path('../../../', __FILE__)
ActiveRecord::Base.transaction do
result = connection.execute("SHOW search_path;")
if schema && !result.first["search_path"].eql?(schema)
connection.execute "SET search_path TO #{schema};"
end
connection.execute(IO.read(gem_root + "/sql/create_column_value.sql"))
connection.execute(IO.read(gem_root + "/sql/get_json_attrs.sql"))
connection.execute(IO.read(gem_root + "/sql/update_history.sql"))
connection.execute(IO.read(gem_root + "/sql/update_bulk_history.sql"))
connection.execute(IO.read(gem_root + "/sql/update_latest.sql"))
end
end
|