From e1054b0474a158417373815eee14e91b7fbad74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Wed, 23 Apr 2025 15:09:23 +0200 Subject: [PATCH] Fix clickhouse migration (#11699) It looks like Clickhouse Cloud uses a different config var than the docs --- .../clickhouse/migrations/run-migrations.ts | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts b/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts index f824fb4bb..4a9697fb1 100644 --- a/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts +++ b/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts @@ -2,7 +2,7 @@ import fs from 'fs'; import path from 'path'; -import { createClient, ClickHouseClient } from '@clickhouse/client'; +import { ClickHouseClient, createClient } from '@clickhouse/client'; import { config } from 'dotenv'; config({ @@ -29,9 +29,30 @@ async function ensureDatabaseExists() { await client.command({ query: `CREATE DATABASE IF NOT EXISTS "${database}"`, }); - await client.command({ - query: `SET enable_json_type = 1`, - }); + + let jsonTypeEnabled = false; + + try { + await client.command({ + query: `SET enable_json_type = 1`, + }); + jsonTypeEnabled = true; + } catch (error) { + // Intentionally empty - will try alternative method + } + + try { + await client.command({ + query: `SET allow_experimental_json_type = 1`, + }); + jsonTypeEnabled = true; + } catch (error) { + // Intentionally empty - failure handled by jsonTypeEnabled check + } + + if (!jsonTypeEnabled) { + console.error('Failed to enable JSON type'); + } await client.close(); }