Class: TableCopy::PG::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/table_copy/pg/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, name, columns) ⇒ Index

Returns a new instance of Index.



6
7
8
9
10
# File 'lib/table_copy/pg/index.rb', line 6

def initialize(table, name, columns)
  @table   = table
  @name    = name
  @columns = columns
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



4
5
6
# File 'lib/table_copy/pg/index.rb', line 4

def columns
  @columns
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/table_copy/pg/index.rb', line 4

def name
  @name
end

#tableObject (readonly)

Returns the value of attribute table.



4
5
6
# File 'lib/table_copy/pg/index.rb', line 4

def table
  @table
end

Instance Method Details

#createObject



12
13
14
# File 'lib/table_copy/pg/index.rb', line 12

def create
  @create ||= "create index on #{table} using btree (#{columns.join(', ')})"
end

#dropObject



16
17
18
# File 'lib/table_copy/pg/index.rb', line 16

def drop
  @drop ||= "drop index if exists #{name}"
end