Class: StagingTable::Adapters::Postgresql

Inherits:
Base
  • Object
show all
Defined in:
lib/staging_table/adapters/postgresql.rb

Instance Attribute Summary

Attributes inherited from Base

#connection

Instance Method Summary collapse

Methods inherited from Base

#drop_table, for, #initialize

Constructor Details

This class inherits a constructor from StagingTable::Adapters::Base

Instance Method Details

#create_table(temp_table_name, source_table_name, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/staging_table/adapters/postgresql.rb', line 6

def create_table(temp_table_name, source_table_name, options = {})
  quoted_temp = connection.quote_table_name(temp_table_name)
  quoted_source = connection.quote_table_name(source_table_name)
  sql = "CREATE TABLE #{quoted_temp} (LIKE #{quoted_source} INCLUDING DEFAULTS"
  sql += " INCLUDING INDEXES" if options[:include_indexes]
  sql += ")"
  connection.execute(sql)
end