Class: ActiveRecord::ConnectionAdapters::IndexDefinition
- Inherits:
-
Struct
- Object
- Struct
- ActiveRecord::ConnectionAdapters::IndexDefinition
- Includes:
- SchemaProcs
- Defined in:
- lib/connection_adapters/index_definition.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#table ⇒ Object
Returns the value of attribute table.
-
#unique ⇒ Object
Returns the value of attribute unique.
Instance Method Summary collapse
Methods included from SchemaProcs
#behavior, #cascade_or_restrict, #definer_or_invoker, #strict_or_null
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns
3 4 5 |
# File 'lib/connection_adapters/index_definition.rb', line 3 def columns @columns end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/connection_adapters/index_definition.rb', line 3 def name @name end |
#table ⇒ Object
Returns the value of attribute table
3 4 5 |
# File 'lib/connection_adapters/index_definition.rb', line 3 def table @table end |
#unique ⇒ Object
Returns the value of attribute 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, ={} 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", ={}) 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, ))} ON #{table}" # "DROP SCHEMA #{name.to_sql_name} #{cascade_or_restrict(options[:cascade])}" # TODO - [ IF EXISTS ] end end |