From 091ac6e8a5b663fbac12f5cfd31c59f2592138d4 Mon Sep 17 00:00:00 2001 From: fenos Date: Fri, 13 Oct 2023 11:07:11 +0100 Subject: [PATCH] fix: allow setting null poolUrl --- src/http/routes/tenant/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/http/routes/tenant/index.ts b/src/http/routes/tenant/index.ts index bfd1c4b8..4d64e112 100644 --- a/src/http/routes/tenant/index.ts +++ b/src/http/routes/tenant/index.ts @@ -22,7 +22,7 @@ const patchSchema = { properties: { anonKey: { type: 'string' }, databaseUrl: { type: 'string' }, - databasePoolUrl: { type: 'string' }, + databasePoolUrl: { type: 'string', nullable: true }, maxConnections: { type: 'number' }, fileSizeLimit: { type: 'number' }, jwtSecret: { type: 'string' }, @@ -193,11 +193,16 @@ export default async function routes(fastify: FastifyInstance) { if (databaseUrl) { await runMigrations(tenantId, databaseUrl) } + console.log(databasePoolUrl, databasePoolUrl === null) await knex('tenants') .update({ anon_key: anonKey !== undefined ? encrypt(anonKey) : undefined, database_url: databaseUrl !== undefined ? encrypt(databaseUrl) : undefined, - database_pool_url: databasePoolUrl !== undefined ? encrypt(databasePoolUrl) : undefined, + database_pool_url: databasePoolUrl + ? encrypt(databasePoolUrl) + : databasePoolUrl === null + ? null + : undefined, max_connections: maxConnections ? Number(maxConnections) : undefined, file_size_limit: fileSizeLimit, jwt_secret: jwtSecret !== undefined ? encrypt(jwtSecret) : undefined,