From 4c4fc6155ac5de40fdd4844a637c133e96899e46 Mon Sep 17 00:00:00 2001 From: Valentin Voronov Date: Wed, 14 Aug 2024 15:52:58 +0300 Subject: [PATCH] fix AssertionError in snuba 0006_sorting_key_change migration If timestamp already DateTime CODEC(T64, ZSTD(1)) migration fails. --- .../querylog/0006_sorting_key_change.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snuba/snuba_migrations/querylog/0006_sorting_key_change.py b/snuba/snuba_migrations/querylog/0006_sorting_key_change.py index 134e1d27b0..ace42d8b35 100644 --- a/snuba/snuba_migrations/querylog/0006_sorting_key_change.py +++ b/snuba/snuba_migrations/querylog/0006_sorting_key_change.py @@ -38,11 +38,11 @@ def update_querylog_table(clickhouse: ClickhousePool, database: str) -> None: # Update the timestamp column # Clickhouse 20 does not support altering a column in the primary key so we need to do it here new_timestamp_type = "`timestamp` DateTime CODEC(T64, ZSTD(1))" - assert new_create_table_statement.count(new_timestamp_type) == 0 - assert new_create_table_statement.count("`timestamp` DateTime") == 1 - new_create_table_statement = new_create_table_statement.replace( - "`timestamp` DateTime", new_timestamp_type - ) + if new_create_table_statement.count(new_timestamp_type) == 0: + assert new_create_table_statement.count("`timestamp` DateTime") == 1 + new_create_table_statement = new_create_table_statement.replace( + "`timestamp` DateTime", new_timestamp_type + ) assert new_timestamp_type in new_create_table_statement # Create the new table