-
-
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 replay_id column to merged discover table (#5777)
* feat(replays): add replay_id column to merged discover table * dont use legacy migration
- Loading branch information
Showing
2 changed files
with
57 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
56 changes: 56 additions & 0 deletions
56
snuba/snuba_migrations/discover/0008_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,56 @@ | ||
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), | ||
] | ||
] | ||
|
||
def forwards_local(self) -> Sequence[operations.SqlOperation]: | ||
return self.forwards_ops() | ||
|
||
def backwards_local(self) -> Sequence[operations.SqlOperation]: | ||
return self.backwards_ops() | ||
|
||
def forwards_dist(self) -> Sequence[operations.SqlOperation]: | ||
return self.forwards_ops() | ||
|
||
def backwards_dist(self) -> Sequence[operations.SqlOperation]: | ||
return self.backwards_ops() |