forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration to backfill accounts.deleted_at
- Loading branch information
1 parent
e059051
commit 82d21e5
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
db/post_migrate/20231122145507_backfill_account_deleted_at.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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class BackfillAccountDeletedAt < ActiveRecord::Migration[6.1] | ||
def up | ||
safety_assured do | ||
execute 'UPDATE accounts SET deleted_at = suspended_at, suspended_at = NULL WHERE domain IS NULL AND suspended_at IS NOT NULL AND NOT EXISTS (SELECT 1 FROM users WHERE account_id = accounts.id)' | ||
end | ||
end | ||
|
||
def down | ||
safety_assured do | ||
'UPDATE accounts SET suspended_at = deleted_at WHERE domain is NULL AND suspended_at IS NULL AND deleted_at IS NOT NULL' | ||
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