Sha256: a08bf826e4cd8facc1894c7e32cf2a3c395340e9c39727fa9362179700203b8b

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

class AddExtendedAttributesToTickets < ActiveRecord::Migration
  def up
    add_column :tickets, :extended_attributes, :hstore
    
    Ticket.reset_column_information
    
    Ticket.nosync do
      Ticket.unscoped.find_each do |ticket|
        
        if ticket.project.nil?
          ticket.delete
          next
        end
        
        
        attrs = {}
        
        unless ticket.estimated_effort.blank? or ticket.estimated_effort.zero?
          attrs["estimated_effort"] = ticket.estimated_effort
        end
        
        unless ticket.estimated_value.blank? or ticket.estimated_value.zero?
          attrs["estimated_value"] = ticket.estimated_value
        end
        
        ticket.update_attribute(:extended_attributes, attrs) unless attrs.empty?
        
      end
    end
  end
  
  def down
    remove_column :tickets, :extended_attributes
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 db/migrate/20130119204608_add_extended_attributes_to_tickets.rb