Skip to content

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

feat: added expiresAt and corrected the ttl part as well

=5ed8bdb3e8db
diff --git a/backend/src/db/clickhouse-migration-runner.ts b/backend/src/db/clickhouse-migration-runner.ts
index db13ebea63..78c1705d8d 100644
--- a/backend/src/db/clickhouse-migration-runner.ts
+++ b/backend/src/db/clickhouse-migration-runner.ts
@@ -14,12 +14,14 @@ CREATE TABLE IF NOT EXISTS ${tableName}
userAgentType LowCardinality(String),
createdAt DateTime64(6) CODEC(DoubleDelta, ZSTD(3)),
orgId UUID,
- projectId String
+ projectId String,
+ expiresAt DateTime64(6)
)
ENGINE = ${engine}
PARTITION BY toYYYYMM(createdAt)
PRIMARY KEY (orgId, projectId, createdAt, id)
ORDER BY (orgId, projectId, createdAt, id)
+TTL toDateTime(expiresAt)
`;
export type TEnsureClickHouseSchemaOpts = {
diff --git a/backend/src/ee/services/audit-log/audit-log-queue.ts b/backend/src/ee/services/audit-log/audit-log-queue.ts
index 5f0a369eeb..d7def1ca95 100644
--- a/backend/src/ee/services/audit-log/audit-log-queue.ts
+++ b/backend/src/ee/services/audit-log/audit-log-queue.ts
@@ -70,7 +70,7 @@ export const auditLogQueueServiceFactory = async ({
const ttl = ttlInDays * MS_IN_DAY;
- if (plan.auditLogsRetentionDays !== 0) {
+ if (ttl > 0) {
await keyStore.streamAdd(AUDIT_LOG_CLICKHOUSE_STREAM_KEY, "*", {
data: JSON.stringify({
id: randomUUID(),
@@ -84,8 +84,7 @@ export const auditLogQueueServiceFactory = async ({
projectId: projectId ?? "",
orgId,
expiresAt: new Date(Date.now() + ttl),
- createdAt: new Date(),
- updatedAt: new Date()
+ createdAt: new Date()
})
});
}