Class: ActiveRecord::ConnectionAdapters::IndexDefinition

Inherits:
Struct
  • Object
show all
Includes:
SchemaProcs
Defined in:
lib/connection_adapters/index_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SchemaProcs

#behavior, #cascade_or_restrict, #definer_or_invoker, #strict_or_null

Instance Attribute Details

#columnsObject

Returns the value of attribute columns

Returns:

  • (Object)

    the current value of columns



3
4
5
# File 'lib/connection_adapters/index_definition.rb', line 3

def columns
  @columns
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/connection_adapters/index_definition.rb', line 3

def name
  @name
end

#tableObject

Returns the value of attribute table

Returns:

  • (Object)

    the current value of table



3
4
5
# File 'lib/connection_adapters/index_definition.rb', line 3

def table
  @table
end

#uniqueObject

Returns the value of attribute unique

Returns:

  • (Object)

    the current value of unique



3
4
5
# File 'lib/connection_adapters/index_definition.rb', line 3

def unique
  @unique
end

Instance Method Details

#to_rdl(add = true, options = {}) ⇒ Object



6
7
8
9
# File 'lib/connection_adapters/index_definition.rb', line 6

def to_rdl add=true, options={}
  return "  add_index #{table.inspect}, #{columns.inspect}, :name => #{name.inspect}#{', :unique => true' if unique || unique == 't'}" if add
#        "  remove_index #{table.inspect}, #{columns.inspect}, :name => #{name.inspect}#{', :unique => true' if unique || unique == 't'}" if add
end

#to_sql(action = "create", options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/connection_adapters/index_definition.rb', line 11

def to_sql(action="create", options={})
  case action
    when "create", :create
        "CREATE INDEX #{name.to_sql_name}"
    # TODO - [ schema_element ]
    when "drop", :drop
      "DROP INDEX #{quote_column_name(index_name(table, options))} ON #{table}"
#            "DROP SCHEMA #{name.to_sql_name} #{cascade_or_restrict(options[:cascade])}"
    # TODO - [ IF EXISTS ]
  end
end