Use migration classes in migrations where current definition conflicts with older (#26390)

This commit is contained in:
Matt Jankowski 2023-08-09 05:26:42 -04:00 committed by GitHub
parent b12d75ef4f
commit 271d384fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 21 deletions

View file

@ -3,8 +3,15 @@
class FillAccountSuspensionOrigin < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
class MigrationAccount < ApplicationRecord
self.table_name = :accounts
scope :suspended, -> { where.not(suspended_at: nil) }
enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
end
def up
Account.suspended.where(suspension_origin: nil).in_batches.update_all(suspension_origin: :local)
MigrationAccount.reset_column_information
MigrationAccount.suspended.where(suspension_origin: nil).in_batches.update_all(suspension_origin: :local)
end
def down; end