Skip to content

Commit

Permalink
fix(group-attributes): Modify the column type for `group_first_releas…
Browse files Browse the repository at this point in the history
…e_id` to bigint (#6040)

* Modify the column type to bigint

* Fix types

* Add migration to group_loader

* Add OperationTarget
  • Loading branch information
snigdhas authored Jun 20, 2024
1 parent 7ec66c7 commit 270e64b
Show file tree
Hide file tree
Showing 2 changed files with 48 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 @@ -400,6 +400,7 @@ def get_migrations(self) -> Sequence[str]:
"0001_group_attributes",
"0002_add_priority_to_group_attributes",
"0003_add_first_release_id_to_group_attributes",
"0004_fix_group_first_release_id_type",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from typing import Sequence

from snuba.clickhouse.columns import UUID, Column, UInt
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, SqlOperation


class Migration(migration.ClickhouseNodeMigration):
blocking = False

def forwards_ops(self) -> Sequence[SqlOperation]:
return [
operations.ModifyColumn(
storage_set=StorageSetKey.GROUP_ATTRIBUTES,
table_name="group_attributes_local",
column=Column(
"group_first_release_id", UInt(64, Modifiers(nullable=True))
),
target=OperationTarget.LOCAL,
),
operations.ModifyColumn(
storage_set=StorageSetKey.GROUP_ATTRIBUTES,
table_name="group_attributes_dist",
column=Column(
"group_first_release_id", UInt(64, Modifiers(nullable=True))
),
target=OperationTarget.DISTRIBUTED,
),
]

def backwards_ops(self) -> Sequence[SqlOperation]:
return [
operations.ModifyColumn(
storage_set=StorageSetKey.GROUP_ATTRIBUTES,
table_name="group_attributes_dist",
column=Column("group_first_release_id", UUID(Modifiers(nullable=True))),
target=OperationTarget.DISTRIBUTED,
),
operations.ModifyColumn(
storage_set=StorageSetKey.GROUP_ATTRIBUTES,
table_name="group_attributes_local",
column=Column("group_first_release_id", UUID(Modifiers(nullable=True))),
target=OperationTarget.LOCAL,
),
]

0 comments on commit 270e64b

Please sign in to comment.