From 553fd812ecc28179faa97c4831f0dbab1a8f6150 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Tue, 25 Jun 2024 13:27:50 -0700 Subject: [PATCH] feat(group-attributes): Add new column for group first release (#6055) Add a new column with a different name for the Group.first_release field to the GroupAttributes table. --- ...irst_release_column_to_group_attributes.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 snuba/snuba_migrations/group_attributes/0004_add_new_first_release_column_to_group_attributes.py diff --git a/snuba/snuba_migrations/group_attributes/0004_add_new_first_release_column_to_group_attributes.py b/snuba/snuba_migrations/group_attributes/0004_add_new_first_release_column_to_group_attributes.py new file mode 100644 index 0000000000..6c937d5b3c --- /dev/null +++ b/snuba/snuba_migrations/group_attributes/0004_add_new_first_release_column_to_group_attributes.py @@ -0,0 +1,51 @@ +from typing import Sequence + +from snuba.clickhouse.columns import 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.AddColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_local", + column=Column( + "group_first_release", + UInt(64, Modifiers(nullable=True)), + ), + target=OperationTarget.LOCAL, + after="group_priority", + ), + operations.AddColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_dist", + column=Column( + "group_first_release", + UInt(64, Modifiers(nullable=True)), + ), + target=OperationTarget.DISTRIBUTED, + after="group_priority", + ), + ] + + def backwards_ops(self) -> Sequence[SqlOperation]: + return [ + operations.DropColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_dist", + column_name="group_first_release", + target=OperationTarget.DISTRIBUTED, + ), + operations.DropColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_local", + column_name="group_first_release", + target=OperationTarget.LOCAL, + ), + ]