Skip to content

Commit

Permalink
sessions: drop the clickhouse tables (#5882)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnagara committed May 13, 2024
1 parent be369fd commit 88b8486
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
1 change: 1 addition & 0 deletions snuba/migrations/group_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def get_migrations(self) -> Sequence[str]:
"0002_sessions_aggregates",
"0003_sessions_matview",
"0004_sessions_ttl",
"0005_drop_sessions_tables",
]


Expand Down
28 changes: 6 additions & 22 deletions snuba/snuba_migrations/sessions/0002_sessions_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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 []
41 changes: 41 additions & 0 deletions snuba/snuba_migrations/sessions/0005_drop_sessions_tables.py
Original file line number Diff line number Diff line change
@@ -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 []

0 comments on commit 88b8486

Please sign in to comment.