From 59bfc204074a93bbe5607c0d1d9ea1757d62e826 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Thu, 20 Jun 2024 16:18:51 -0700 Subject: [PATCH 1/3] Drop group_first_release_id column --- ..._first_release_id_from_group_attributes.py | 51 +++++++++++++++++++ snuba/migrations/group_loader.py | 1 + 2 files changed, 52 insertions(+) create mode 100644 snuba/migrations/0004_drop_first_release_id_from_group_attributes.py diff --git a/snuba/migrations/0004_drop_first_release_id_from_group_attributes.py b/snuba/migrations/0004_drop_first_release_id_from_group_attributes.py new file mode 100644 index 0000000000..63f944fddf --- /dev/null +++ b/snuba/migrations/0004_drop_first_release_id_from_group_attributes.py @@ -0,0 +1,51 @@ +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, SqlOperation + + +class Migration(migration.ClickhouseNodeMigration): + blocking = False + + def forwards_ops(self) -> Sequence[SqlOperation]: + return [ + operations.DropColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_local", + column_name="group_first_release_id", + target=OperationTarget.LOCAL, + ), + operations.DropColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_dist", + column_name="group_first_release_id", + target=OperationTarget.DISTRIBUTED, + ), + ] + + def backwards_ops(self) -> Sequence[SqlOperation]: + return [ + operations.AddColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_dist", + column=Column( + "group_first_release_id", + UUID(Modifiers(nullable=True)), + ), + target=OperationTarget.DISTRIBUTED, + after="group_priority", + ), + operations.AddColumn( + storage_set=StorageSetKey.GROUP_ATTRIBUTES, + table_name="group_attributes_local", + column=Column( + "group_first_release_id", + UUID(Modifiers(nullable=True)), + ), + target=OperationTarget.LOCAL, + after="group_priority", + ), + ] diff --git a/snuba/migrations/group_loader.py b/snuba/migrations/group_loader.py index 2cbc098784..890db973e1 100644 --- a/snuba/migrations/group_loader.py +++ b/snuba/migrations/group_loader.py @@ -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_drop_first_release_id_from_group_attributes", ] From c814b61762d84c362417e21f7dfdeb994379f797 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Fri, 21 Jun 2024 10:56:45 -0700 Subject: [PATCH 2/3] Move migration to the right directory --- .../0004_drop_first_release_id_from_group_attributes.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename snuba/{migrations => snuba_migrations/group_attributes}/0004_drop_first_release_id_from_group_attributes.py (100%) diff --git a/snuba/migrations/0004_drop_first_release_id_from_group_attributes.py b/snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py similarity index 100% rename from snuba/migrations/0004_drop_first_release_id_from_group_attributes.py rename to snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py From 754c98901b4240cfba79b09e72270f488426d7b5 Mon Sep 17 00:00:00 2001 From: Snigdha Sharma Date: Fri, 21 Jun 2024 11:26:02 -0700 Subject: [PATCH 3/3] Switch the drop order --- ...rop_first_release_id_from_group_attributes.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py b/snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py index 63f944fddf..b06aba3557 100644 --- a/snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py +++ b/snuba/snuba_migrations/group_attributes/0004_drop_first_release_id_from_group_attributes.py @@ -14,15 +14,15 @@ def forwards_ops(self) -> Sequence[SqlOperation]: return [ operations.DropColumn( storage_set=StorageSetKey.GROUP_ATTRIBUTES, - table_name="group_attributes_local", + table_name="group_attributes_dist", column_name="group_first_release_id", - target=OperationTarget.LOCAL, + target=OperationTarget.DISTRIBUTED, ), operations.DropColumn( storage_set=StorageSetKey.GROUP_ATTRIBUTES, - table_name="group_attributes_dist", + table_name="group_attributes_local", column_name="group_first_release_id", - target=OperationTarget.DISTRIBUTED, + target=OperationTarget.LOCAL, ), ] @@ -30,22 +30,22 @@ def backwards_ops(self) -> Sequence[SqlOperation]: return [ operations.AddColumn( storage_set=StorageSetKey.GROUP_ATTRIBUTES, - table_name="group_attributes_dist", + table_name="group_attributes_local", column=Column( "group_first_release_id", UUID(Modifiers(nullable=True)), ), - target=OperationTarget.DISTRIBUTED, + target=OperationTarget.LOCAL, after="group_priority", ), operations.AddColumn( storage_set=StorageSetKey.GROUP_ATTRIBUTES, - table_name="group_attributes_local", + table_name="group_attributes_dist", column=Column( "group_first_release_id", UUID(Modifiers(nullable=True)), ), - target=OperationTarget.LOCAL, + target=OperationTarget.DISTRIBUTED, after="group_priority", ), ]