Module: ArJdbc::Oracle

Defined in:
lib/hatio-core/patch/string_key.rb

Instance Method Summary collapse

Instance Method Details

#create_table(table_name, options = {}) {|table_definition| ... } ⇒ Object

Yields:

  • (table_definition)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/hatio-core/patch/string_key.rb', line 36

def create_table(table_name, options = {})
  puts "oracel patch"
  table_definition = TableDefinition.new(self)
  table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false || options[:id] == :meaningful || options[:id] == :uuid

  yield table_definition

  if options[:force] && table_exists?(table_name)
    drop_table(table_name, options)
  end

  create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
  create_sql << "#{quote_table_name(table_name)} ("
  create_sql << "id varchar(#{options[:id_limit] || 64}) NOT NULL PRIMARY KEY, " if options[:id] == :meaningful || options[:id] == :uuid
  create_sql << table_definition.to_sql
  create_sql << ") #{options[:options]}"
  execute create_sql
end