Skip to content

Commit

Permalink
[#330] added migration for deleting draft accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Stepanov committed Dec 2, 2022
1 parent 3a4dc7c commit c07e98e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/app/services/uffizzi_core/migrations/account_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class UffizziCore::Migrations::AccountService
class << self
def remove_draft_accounts
UffizziCore::Account.where(state: 'draft').find_each do |account|
account.owner.destroy
account.destroy
end
end
end
end
9 changes: 9 additions & 0 deletions core/lib/tasks/migration/accounts.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

namespace :migration do
desc 'destroy all draft accounts'
task migrate_draft_accounts: :environment do
UffizziCore::Migrations::AccountService.remove_draft_accounts
puts 'Success'
end
end

0 comments on commit c07e98e

Please sign in to comment.