Sha256: 9fe5b3a680ffb5e4e80bc446966acd6fb0296d1f819f7e0968d91f2116a7fcec

Contents?: true

Size: 674 Bytes

Versions: 14

Compression:

Stored size: 674 Bytes

Contents

class AddProjectIdToTestingNotes < ActiveRecord::Migration
  def up
    add_column :testing_notes, :project_id, :integer

    TestingNote.reset_column_information
    TestingNote.find_each do |testing_note|
      ticket = testing_note.ticket

      if ticket.nil?
        testing_note.delete
        Rails.logger.warn "Deleting testing_note ##{testing_note.id} (#{testing_note.attributes.inspect})"
        next
      end

      testing_note.update_column(:project_id, ticket.project_id)
    end

    change_column_null :testing_notes, :project_id, false

    add_index :testing_notes, [:project_id]
  end

  def down
    remove_column :testing_notes, :project_id
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
houston-core-0.7.0.beta3 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.7.0.beta2 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.7.0.beta db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.6.3 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.6.2 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.6.1 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.6.0 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.6 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.5 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.4 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.3 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.2 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.1 db/migrate/20130407220039_add_project_id_to_testing_notes.rb
houston-core-0.5.0 db/migrate/20130407220039_add_project_id_to_testing_notes.rb