Skip to content

Commit

Permalink
feat(replays): add replay_id column to merged discover table (#5777)
Browse files Browse the repository at this point in the history
* feat(replays): add replay_id column to merged discover table

* dont use legacy migration
  • Loading branch information
JoshFerge authored Apr 16, 2024
1 parent 656d28c commit 55d2efc
Show file tree
Hide file tree
Showing 2 changed files with 57 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 @@ -136,6 +136,7 @@ def get_migrations(self) -> Sequence[str]:
"0005_discover_fix_transaction_name",
"0006_discover_add_trace_id",
"0007_discover_add_span_id",
"0008_discover_add_replay_id",
]


Expand Down
56 changes: 56 additions & 0 deletions snuba/snuba_migrations/discover/0008_discover_add_replay_id.py
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()

0 comments on commit 55d2efc

Please sign in to comment.