Class: Spider::Migrations::DropElement
- Inherits:
-
IrreversibleMigration
- Object
- Migration
- IrreversibleMigration
- Spider::Migrations::DropElement
- Defined in:
- lib/spiderfw/model/migrations/drop_element.rb
Instance Method Summary collapse
-
#initialize(model, element, options = {}) ⇒ DropElement
constructor
A new instance of DropElement.
- #run ⇒ Object
Methods inherited from IrreversibleMigration
Constructor Details
#initialize(model, element, options = {}) ⇒ DropElement
Returns a new instance of DropElement.
5 6 7 8 9 |
# File 'lib/spiderfw/model/migrations/drop_element.rb', line 5 def initialize(model, element, ={}) @model = model @element = element @options = end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spiderfw/model/migrations/drop_element.rb', line 11 def run field = @options[:field_name] if !field schema_field = @model.mapper.schema.field(@element) field = schema_field.name if schema_field end field ||= @model.mapper.storage.column_name(@element) desc = @model.mapper.storage.describe_table(@model.mapper.schema.table) if desc[:columns][field] @model.mapper.storage.drop_field(@model.mapper.schema.table, field) end end |