From 0b729cb0006b622c5f1a5a7a9730ea41821e3113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Malfait?= Date: Wed, 23 Apr 2025 22:08:52 +0200 Subject: [PATCH] Fix json type in clickhouse migrations (#11710) Settings in clickhouse are only set for the duration of the session so we need to keep the same client --- .../clickhouse/migrations/run-migrations.ts | 27 +++---------------- 1 file changed, 3 insertions(+), 24 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 4a9697fb1..1ce772c3d 100644 --- a/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts +++ b/packages/twenty-server/src/database/clickhouse/migrations/run-migrations.ts @@ -30,30 +30,6 @@ async function ensureDatabaseExists() { query: `CREATE DATABASE IF NOT EXISTS "${database}"`, }); - 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(); } @@ -99,6 +75,9 @@ async function runMigrations() { const client = createClient({ url: clickhouseUrl(), + clickhouse_settings: { + allow_experimental_json_type: 1, + }, }); await ensureMigrationTable(client);