-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCT-2325 Update timeout list for E6 (#631)
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
backend/migrations/versions/976c7c2adb0f_soft_delete_allocations_for_selected_.py
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,58 @@ | ||
"""Soft delete allocations for selected users | ||
Revision ID: 976c7c2adb0f | ||
Revises: 6ab87f7762d8 | ||
Create Date: 2025-01-15 09:44:48.635057 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from eth_utils import to_checksum_address | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "976c7c2adb0f" | ||
down_revision = "6ab87f7762d8" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
epoch = 6 | ||
addresses = [ | ||
"0x33878e070db7f70d2953fe0278cd32adf8104572", | ||
"0x094b75eedf58a83af4d37694b7532691fb26570e", | ||
] | ||
# INFO: remember to checksum addresses :) | ||
checksum_addresses = [to_checksum_address(address) for address in addresses] | ||
|
||
soft_delete_allocations_query = """\ | ||
UPDATE allocations | ||
SET deleted_at = CURRENT_TIMESTAMP | ||
WHERE epoch = :epoch | ||
AND user_id IN (SELECT id FROM users WHERE address IN :addresses) | ||
AND deleted_at IS NULL; | ||
""" | ||
|
||
delete_uniqueness_quotients_query = """\ | ||
DELETE FROM uniqueness_quotients | ||
WHERE epoch = :epoch | ||
AND user_id IN (SELECT id FROM users WHERE address IN :addresses); | ||
""" | ||
|
||
session = op.get_context().bind | ||
|
||
session.execute( | ||
sa.text(soft_delete_allocations_query), | ||
{"epoch": epoch, "addresses": tuple(checksum_addresses)}, | ||
) | ||
session.execute( | ||
sa.text(delete_uniqueness_quotients_query), | ||
{"epoch": epoch, "addresses": tuple(checksum_addresses)}, | ||
) | ||
|
||
session.commit() | ||
|
||
|
||
def downgrade(): | ||
# We don't downgrade this migration | ||
pass |