Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20180430134444_add_completed_at_to_account_migration.rb « migrate « db - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 13eff4c85ddc265fb441fd781d8a6a5e5aa010df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class AddCompletedAtToAccountMigration < ActiveRecord::Migration[5.1]
  def change
    add_column :account_migrations, :completed_at, :datetime, default: nil

    reversible do |change|
      change.up do
        set_completed_at_for_closed_accounts
      end
    end
  end

  def set_completed_at_for_closed_accounts
    # rubocop:disable Rails/SkipsModelValidations
    AccountMigration.joins(:old_person).where(people: {closed_account: true}).update_all(completed_at: Time.zone.now)
    # rubocop:enable Rails/SkipsModelValidations
  end
end