Sha256: ee90383aac07015ba70916ed5b93a04ff0788ddd1acb3561b6f0ec36ce3b08e0

Contents?: true

Size: 678 Bytes

Versions: 29

Compression:

Stored size: 678 Bytes

Contents

class AddStartedAtAndEndedAtOnTasks < ActiveRecord::Migration[4.2]
  def up
    add_column :tasks, :started_at, :datetime, null: true
    add_column :tasks, :ended_at, :datetime, null: true

    say "Migrating #{Shipit::Task.count} tasks:"
    Shipit::Task.find_each.with_index do |task, index|
      unless task.started_at
        task.update_columns(
          started_at: task.created_at,
          ended_at: task.updated_at, # good enough approximation but not perfect
        )
        puts if index % 100 == 0
        print '.'
      end
    end
    puts
    say "Done"
  end

  def down
    remove_column :tasks, :started_at
    remove_column :tasks, :ended_at
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.38.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.37.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.36.1 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.36.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.35.1 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.35.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.34.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.33.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.32.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.31.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.30.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.29.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.28.1 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.28.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.27.1 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.27.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.26.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.25.1 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb
shipit-engine-0.25.0 db/migrate/20160324155046_add_started_at_and_ended_at_on_tasks.rb