Sha256: c6cac2423b8466c3a01351a74366e706d3b25dd12d5629c5068cf2840d541cbf

Contents?: true

Size: 266 Bytes

Versions: 33

Compression:

Stored size: 266 Bytes

Contents

class DeleteOrphanStatuses < ActiveRecord::Migration[5.0]
  def up
    ids = Shipit::Status.left_joins(:commit).where(commits: {id: nil}).pluck(:id)
    say "Found #{ids.size} orphan statuses"
    Shipit::Status.where(id: ids).delete_all
  end

  def down
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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