Skip to content

Commit 8b02cdb

Browse files
committed
opt-in migration
1 parent 2653b4e commit 8b02cdb

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

integration-tests/docker-compose.integration.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ networks:
1010
name: hive
1111

1212
services:
13+
migrations:
14+
environment:
15+
CLICKHOUSE_OPERATIONS_V01_ROLLUPS: '1'
16+
1317
local_cdn:
1418
image: node${NODE_VERSION_TAG}
1519
working_dir: /app

packages/migrations/.env.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ POSTGRES_USER=postgres
1414
POSTGRES_PASSWORD=postgres
1515
POSTGRES_HOST=localhost
1616
POSTGRES_PORT=5432
17-
POSTGRES_DB=registry
17+
POSTGRES_DB=registry
18+
19+
CLICKHOUSE_OPERATIONS_V01_ROLLUPS=1

packages/migrations/src/clickhouse.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type Action = (
2626

2727
export async function migrateClickHouse(
2828
isClickHouseMigrator: boolean,
29+
enableOperationsV01Rollups: boolean,
2930
isHiveCloud: boolean,
3031
hiveCloudEnvironment: 'prod' | 'staging' | 'dev' | null,
3132
clickhouse: {
@@ -197,6 +198,12 @@ export async function migrateClickHouse(
197198
return;
198199
}
199200

201+
// Keep the v01 rollup tables opt-in without recording the migration as completed.
202+
if (index === 21 && !enableOperationsV01Rollups) {
203+
console.log(' Skipping because CLICKHOUSE_OPERATIONS_V01_ROLLUPS_START is not set');
204+
return;
205+
}
206+
200207
try {
201208
await action(
202209
async (query, settings) => {

packages/migrations/src/environment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const EnvironmentModel = zod.object({
3535
RELEASE: emptyString(zod.string().optional()),
3636
MIGRATOR: emptyString(zod.string().optional()),
3737
CLICKHOUSE_MIGRATOR: emptyString(zod.string().optional()),
38+
CLICKHOUSE_OPERATIONS_V01_ROLLUPS: emptyString(
39+
zod.union([zod.literal('1'), zod.literal('0')]).optional(),
40+
),
3841
CLICKHOUSE_MIGRATOR_GRAPHQL_HIVE_CLOUD: zod
3942
.union([zod.literal('1'), zod.literal('0')])
4043
.optional(),
@@ -111,6 +114,7 @@ export const env = {
111114
: null,
112115
isMigrator: base.MIGRATOR === 'up',
113116
isClickHouseMigrator: base.CLICKHOUSE_MIGRATOR === 'up',
117+
enableOperationsV01Rollups: base.CLICKHOUSE_OPERATIONS_V01_ROLLUPS === '1',
114118
isHiveCloud: base.CLICKHOUSE_MIGRATOR_GRAPHQL_HIVE_CLOUD === '1',
115119
hiveCloudEnvironment: base.GRAPHQL_HIVE_ENVIRONMENT ?? null,
116120
} as const;

packages/migrations/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ try {
4848
if (env.clickhouse) {
4949
await migrateClickHouse(
5050
env.isClickHouseMigrator,
51+
env.enableOperationsV01Rollups,
5152
env.isHiveCloud,
5253
env.hiveCloudEnvironment,
5354
env.clickhouse,

0 commit comments

Comments
 (0)