Skip to content

Commit 8ba5ade

Browse files
authored
feat(eap): Add a column to store downsampled retention days (#7318)
1 parent 77f2b84 commit 8ba5ade

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from snuba.clickhouse.columns import Column, UInt
2+
from snuba.clusters.storage_sets import StorageSetKey
3+
from snuba.migrations import migration, operations
4+
from snuba.migrations.columns import MigrationModifiers as Modifiers
5+
from snuba.migrations.operations import OperationTarget
6+
7+
storage_set = StorageSetKey.EVENTS_ANALYTICS_PLATFORM
8+
table_name_prefix = "eap_items_1"
9+
new_column_name = "downsampled_retention_days"
10+
after = "retention_days"
11+
12+
13+
class Migration(migration.ClickhouseNodeMigration):
14+
blocking = False
15+
16+
def forwards_ops(self) -> list[operations.SqlOperation]:
17+
return [
18+
operations.AddColumn(
19+
storage_set=storage_set,
20+
table_name=f"{table_name_prefix}_local",
21+
column=Column(
22+
new_column_name,
23+
UInt(
24+
16,
25+
modifiers=Modifiers(
26+
codecs=[
27+
"ZSTD(1)",
28+
]
29+
),
30+
),
31+
),
32+
after=after,
33+
target=OperationTarget.LOCAL,
34+
),
35+
operations.AddColumn(
36+
storage_set=storage_set,
37+
table_name=f"{table_name_prefix}_dist",
38+
column=Column(
39+
new_column_name,
40+
UInt(
41+
16,
42+
modifiers=Modifiers(
43+
codecs=[
44+
"ZSTD(1)",
45+
]
46+
),
47+
),
48+
),
49+
after=after,
50+
target=OperationTarget.DISTRIBUTED,
51+
),
52+
]
53+
54+
def backwards_ops(self) -> list[operations.SqlOperation]:
55+
return [
56+
operations.DropColumn(
57+
storage_set=storage_set,
58+
table_name=f"{table_name_prefix}_dist",
59+
column_name=new_column_name,
60+
target=OperationTarget.DISTRIBUTED,
61+
),
62+
operations.DropColumn(
63+
storage_set=storage_set,
64+
table_name=f"{table_name_prefix}_local",
65+
column_name=new_column_name,
66+
target=OperationTarget.LOCAL,
67+
),
68+
]

0 commit comments

Comments
 (0)