Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Update local dev env to use infisical for the db name and credentials

Fang-Pen Linbf6b2aab6ef1
diff --git a/.env.example b/.env.example
index 4600de6f2b..785e80cce6 100644
--- a/.env.example
+++ b/.env.example
@@ -139,4 +139,4 @@ DATADOG_HOSTNAME=
KUBERNETES_AUTO_FETCH_SERVICE_ACCOUNT_TOKEN=false
# ClickHouse (optional) for audit log storage
-# CLICKHOUSE_URL=http://default:clickhouse@clickhouse:8123
+# CLICKHOUSE_URL=http://infisical:infisical@clickhouse:8123/infisical
diff --git a/.env.migration.example b/.env.migration.example
index 774d5584c5..5e2b18585a 100644
--- a/.env.migration.example
+++ b/.env.migration.example
@@ -1,3 +1,3 @@
DB_CONNECTION_URI=postgres://infisical:infisical@localhost:5432/infisical
AUDIT_LOGS_DB_CONNECTION_URI=
-CLICKHOUSE_URL=http://default:clickhouse@localhost:8123
+CLICKHOUSE_URL=http://infisical:infisical@localhost:8123/infisical
diff --git a/backend/src/auto-start-migrations.ts b/backend/src/auto-start-migrations.ts
index 65de089f95..19448f4a44 100644
--- a/backend/src/auto-start-migrations.ts
+++ b/backend/src/auto-start-migrations.ts
@@ -332,7 +332,8 @@ export const runMigrations = async ({ applicationDb, auditLogDb, clickhouseClien
await ensureClickHouseSchema({
client: clickhouseClient,
tableName: cfg.CLICKHOUSE_AUDIT_LOG_TABLE_NAME,
- engine: cfg.CLICKHOUSE_AUDIT_LOG_ENGINE
+ engine: cfg.CLICKHOUSE_AUDIT_LOG_ENGINE,
+ logger
});
} catch (clickhouseErr) {
logger.error(clickhouseErr, "ClickHouse schema setup failed");
diff --git a/backend/src/db/clickhouse-migration-runner.ts b/backend/src/db/clickhouse-migration-runner.ts
index 360188ebb3..db13ebea63 100644
--- a/backend/src/db/clickhouse-migration-runner.ts
+++ b/backend/src/db/clickhouse-migration-runner.ts
@@ -1,6 +1,5 @@
import { type ClickHouseClient } from "@clickhouse/client";
-
-import { logger } from "@app/lib/logger";
+import { Logger } from "pino";
const buildCreateAuditLogsTableSQL = (tableName: string, engine: string) => `
CREATE TABLE IF NOT EXISTS ${tableName}
@@ -27,13 +26,14 @@ export type TEnsureClickHouseSchemaOpts = {
client: ClickHouseClient;
tableName: string;
engine: string;
+ logger: Logger;
};
/**
* Ensure the ClickHouse audit_logs table exists.
* If the table already exists, this is a no-op (CREATE TABLE IF NOT EXISTS).
*/
-export const ensureClickHouseSchema = async ({ client, tableName, engine }: TEnsureClickHouseSchemaOpts) => {
+export const ensureClickHouseSchema = async ({ client, tableName, engine, logger }: TEnsureClickHouseSchemaOpts) => {
logger.info({ tableName }, "Ensuring ClickHouse audit_logs table exists");
await client.exec({
diff --git a/backend/src/db/run-clickhouse-migrations.ts b/backend/src/db/run-clickhouse-migrations.ts
index 50c6dbad22..585763897a 100644
--- a/backend/src/db/run-clickhouse-migrations.ts
+++ b/backend/src/db/run-clickhouse-migrations.ts
@@ -16,6 +16,8 @@ import path from "node:path";
import dotenv from "dotenv";
+import { initLogger } from "@app/lib/logger";
+
import { buildClickHouseFromConfig } from "../lib/config/clickhouse";
import { ensureClickHouseSchema } from "./clickhouse-migration-runner";
@@ -51,11 +53,14 @@ const main = async () => {
// eslint-disable-next-line no-console
console.info("Ensuring ClickHouse schema...");
+ const logger = initLogger();
+
try {
await ensureClickHouseSchema({
client,
tableName,
- engine
+ engine,
+ logger
});
// eslint-disable-next-line no-console
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts
index c18aab6ce1..e91fa981e7 100644
--- a/backend/src/lib/config/env.ts
+++ b/backend/src/lib/config/env.ts
@@ -89,7 +89,7 @@ const envSchema = z
z
.string()
.optional()
- .describe("ClickHouse connection URL. Eg: http://localhost:8123 or https://user:password@host:8443/default")
+ .describe("ClickHouse connection URL. Eg: http://localhost:8123 or https://user:password@host:8443/database")
),
CLICKHOUSE_AUDIT_LOG_INSERT_SETTINGS: zpStr(
z
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index a660c624cd..4a689a497e 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -45,9 +45,9 @@ services:
- clickhouse_data:/var/lib/clickhouse
- clickhouse_logs:/var/log/clickhouse-server
environment:
- - CLICKHOUSE_DB=default
- - CLICKHOUSE_USER=default
- - CLICKHOUSE_PASSWORD=clickhouse
+ - CLICKHOUSE_DB=infisical
+ - CLICKHOUSE_USER=infisical
+ - CLICKHOUSE_PASSWORD=infisical
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
ulimits:
nofile: