class Immigrate::ForeignTableDefinition

Constants

NATIVE_DATABASE_TYPES

Attributes

columns[R]
name[R]
server[R]

Public Class Methods

new(name, server) click to toggle source
# File lib/immigrate/foreign_table_definition.rb, line 45
def initialize name, server
  @name = name
  @server = server
  @columns = []
end

Public Instance Methods

column(name, type) click to toggle source
# File lib/immigrate/foreign_table_definition.rb, line 51
def column name, type
  @columns << [name, type]
end
column_definitions() click to toggle source
# File lib/immigrate/foreign_table_definition.rb, line 67
def column_definitions
  columns.map { |column| "#{column.first} #{native_column_type column.second}"}.join(',')
end
native_column_type(type) click to toggle source
# File lib/immigrate/foreign_table_definition.rb, line 71
def native_column_type type
  NATIVE_DATABASE_TYPES[type]
end
sql() click to toggle source
# File lib/immigrate/foreign_table_definition.rb, line 63
def sql
  "CREATE FOREIGN TABLE #{name} (#{column_definitions}) SERVER #{server}"
end