diff --git a/snuba/migrations/group_loader.py b/snuba/migrations/group_loader.py index 2a99fa2206..55702cd648 100644 --- a/snuba/migrations/group_loader.py +++ b/snuba/migrations/group_loader.py @@ -240,6 +240,7 @@ def get_migrations(self) -> Sequence[str]: "0002_sessions_aggregates", "0003_sessions_matview", "0004_sessions_ttl", + "0005_drop_sessions_tables", ] diff --git a/snuba/snuba_migrations/sessions/0002_sessions_aggregates.py b/snuba/snuba_migrations/sessions/0002_sessions_aggregates.py index 83a69ca5f2..bae00a5228 100644 --- a/snuba/snuba_migrations/sessions/0002_sessions_aggregates.py +++ b/snuba/snuba_migrations/sessions/0002_sessions_aggregates.py @@ -80,17 +80,9 @@ def forwards_local(self) -> Sequence[operations.SqlOperation]: ] def backwards_local(self) -> Sequence[operations.SqlOperation]: - return [ - operations.DropColumn( - StorageSetKey.SESSIONS, "sessions_raw_local", column.name - ) - for [column, after] in new_raw_columns - ] + [ - operations.DropColumn( - StorageSetKey.SESSIONS, "sessions_hourly_local", column.name - ) - for [column, after] in new_dest_columns - ] + # Sessions is fully deprecated, we don't need to keep supporting this reverse migration + # as providing it makes test_reverse_idempotency_all fail + return [] def forwards_dist(self) -> Sequence[operations.SqlOperation]: return [ @@ -112,14 +104,6 @@ def forwards_dist(self) -> Sequence[operations.SqlOperation]: ] def backwards_dist(self) -> Sequence[operations.SqlOperation]: - return [ - operations.DropColumn( - StorageSetKey.SESSIONS, "sessions_raw_dist", column.name - ) - for [column, after] in new_raw_columns - ] + [ - operations.DropColumn( - StorageSetKey.SESSIONS, "sessions_hourly_dist", column.name - ) - for [column, after] in new_dest_columns - ] + # Sessions is fully deprecated, we don't need to keep supporting this reverse migration + # as providing it makes test_reverse_idempotency_all fail + return [] diff --git a/snuba/snuba_migrations/sessions/0005_drop_sessions_tables.py b/snuba/snuba_migrations/sessions/0005_drop_sessions_tables.py new file mode 100644 index 0000000000..fc1658d3c7 --- /dev/null +++ b/snuba/snuba_migrations/sessions/0005_drop_sessions_tables.py @@ -0,0 +1,41 @@ +from typing import Sequence + +from snuba.clusters.storage_sets import StorageSetKey +from snuba.migrations import migration, operations + + +class Migration(migration.ClickhouseNodeMigration): + blocking = False + + def forwards_ops(self) -> Sequence[operations.SqlOperation]: + return [ + operations.DropTable( + storage_set=StorageSetKey.SESSIONS, + table_name="sessions_raw_dist", + target=operations.OperationTarget.DISTRIBUTED, + ), + operations.DropTable( + storage_set=StorageSetKey.SESSIONS, + table_name="sessions_hourly_dist", + target=operations.OperationTarget.DISTRIBUTED, + ), + operations.DropTable( + storage_set=StorageSetKey.SESSIONS, + table_name="sessions_hourly_mv_local", + target=operations.OperationTarget.LOCAL, + ), + operations.DropTable( + storage_set=StorageSetKey.SESSIONS, + table_name="sessions_hourly_local", + target=operations.OperationTarget.LOCAL, + ), + operations.DropTable( + storage_set=StorageSetKey.SESSIONS, + table_name="sessions_raw_local", + target=operations.OperationTarget.LOCAL, + ), + ] + + def backwards_ops(self) -> Sequence[operations.SqlOperation]: + # Sessions is fully deprecated, we don't need the reverse migration to bring back the tables + return []