-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#330] added migration for deleting draft accounts
- Loading branch information
Aleksey Stepanov
committed
Dec 2, 2022
1 parent
3a4dc7c
commit c07e98e
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
core/app/services/uffizzi_core/migrations/account_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |