Class: DbDiff::Delta::ModifyKey

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

#initialize, #table, #to_a

Constructor Details

This class inherits a constructor from DbDiff::Delta

Instance Method Details

#process(database) ⇒ Object



166
167
168
169
170
171
# File 'lib/dbdiff/delta.rb', line 166

def process(database)
  table = table(database)
  old_key = table.keys.find{|k| k.name == element.name}
  table.keys.delete(old_key)
  table.keys << element
end

#sqlObject



162
163
164
# File 'lib/dbdiff/delta.rb', line 162

def sql
  "ALTER TABLE #{element.table_name} DROP KEY `#{element.name}`, ADD" + element.definition
end