about summary refs log tree commit diff
path: root/db/migrate/20200110214031_migrate_filter_undescribed_from_accounts.rb
blob: 6e29b9d446163dbb2b3877c3635b832501567749 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class MigrateFilterUndescribedFromAccounts < ActiveRecord::Migration[5.2]
  def up
    Account.local.find_each do |account|
      account.user.update!(filter_undescribed: account.filter_undescribed)
    end
    safety_assured {
      remove_column :accounts, :filter_undescribed
    }
  end

  def down
    return true
    safety_assured {
      add_column :accounts, :filter_undescribed, :boolean, null: true, default: false
    }
  end
end