-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(replays): add migration for replay_id in discover (#5790)
* feat(replays): add migration for replay_id in discover * Update group_loader.py * Update group_loader.py * style(lint): Auto commit lint changes * Update 0008_discover_add_replay_id.py * Rename 0008_discover_add_replay_id.py to 0009_discover_add_replay_id.py --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e0805f1
commit b4186f9
Showing
2 changed files
with
45 additions
and
0 deletions.
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
44 changes: 44 additions & 0 deletions
44
snuba/snuba_migrations/discover/0009_discover_add_replay_id.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,44 @@ | ||
from typing import Sequence | ||
|
||
from snuba.clickhouse.columns import UUID, Column | ||
from snuba.clusters.storage_sets import StorageSetKey | ||
from snuba.migrations import migration, operations | ||
from snuba.migrations.columns import MigrationModifiers as Modifiers | ||
from snuba.migrations.operations import OperationTarget | ||
|
||
|
||
class Migration(migration.ClickhouseNodeMigration): | ||
""" | ||
Add replay_id to merge table | ||
""" | ||
|
||
blocking = False | ||
|
||
def forwards_ops(self) -> Sequence[operations.SqlOperation]: | ||
return [ | ||
operations.AddColumn( | ||
storage_set=StorageSetKey.DISCOVER, | ||
table_name=table_name, | ||
column=Column("replay_id", UUID(Modifiers(nullable=True))), | ||
after="span_id", | ||
target=target, | ||
) | ||
for table_name, target in [ | ||
("discover_local", OperationTarget.LOCAL), | ||
("discover_dist", OperationTarget.DISTRIBUTED), | ||
] | ||
] | ||
|
||
def backwards_ops(self) -> Sequence[operations.SqlOperation]: | ||
return [ | ||
operations.DropColumn( | ||
storage_set=StorageSetKey.DISCOVER, | ||
table_name=table_name, | ||
column_name="replay_id", | ||
target=target, | ||
) | ||
for table_name, target in [ | ||
("discover_dist", OperationTarget.DISTRIBUTED), | ||
("discover_local", OperationTarget.LOCAL), | ||
] | ||
] |