Skip to content

Commit

Permalink
feat(replays): add migration for replay_id in discover (#5790)
Browse files Browse the repository at this point in the history
* 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
JoshFerge and getsantry[bot] authored Apr 18, 2024
1 parent e0805f1 commit b4186f9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions snuba/migrations/group_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def get_migrations(self) -> Sequence[str]:
"0006_discover_add_trace_id",
"0007_discover_add_span_id",
"0008_discover_fix_add_local_table",
"0009_discover_add_replay_id",
]


Expand Down
44 changes: 44 additions & 0 deletions snuba/snuba_migrations/discover/0009_discover_add_replay_id.py
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),
]
]

0 comments on commit b4186f9

Please sign in to comment.