Class: DbDiff::Delta::DropRow

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



140
141
142
143
# File 'lib/dbdiff/delta.rb', line 140

def process(database)
  table = table(database)
  table.rows.delete(element)
end

#sqlObject



134
135
136
137
138
# File 'lib/dbdiff/delta.rb', line 134

def sql
  data = element.data
  where = element.primary_key.map {|k| "#{k}=" + Mysql.escape_string(data[k]) }.join(" AND ")
  return "DELETE FROM #{element.table_name} WHERE #{where}"
end