Class: DbDiff::Delta::AddColumn

Inherits:
DbDiff::Delta show all
Defined in:
lib/dbdiff/delta.rb

Instance Attribute Summary

Attributes inherited from DbDiff::Delta

#element

Instance Method Summary collapse

Methods inherited from DbDiff::Delta

#table, #to_a

Constructor Details

#initialize(element) ⇒ AddColumn

Returns a new instance of AddColumn.



57
58
59
60
# File 'lib/dbdiff/delta.rb', line 57

def initialize(element)
  super
  @element.auto_increment = false
end

Instance Method Details

#process(database) ⇒ Object



66
67
68
69
# File 'lib/dbdiff/delta.rb', line 66

def process(database)
  table = table(database)
  table.columns << element
end

#sqlObject



62
63
64
# File 'lib/dbdiff/delta.rb', line 62

def sql
  "ALTER TABLE #{element.table_name} ADD COLUMN " + element.definition(true)
end