Skip to content

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

chore: remove logs and make the index creation in different files

adilsond7295f65f4b8
diff --git a/backend/src/db/migrations/20260716120000_resource-metadata-search-index.ts b/backend/src/db/migrations/20260716120000_resource-metadata-org-id-key-index.ts
similarity index 76%
rename from backend/src/db/migrations/20260716120000_resource-metadata-search-index.ts
rename to backend/src/db/migrations/20260716120000_resource-metadata-org-id-key-index.ts
index a26ff7898b..480fd95319 100644
--- a/backend/src/db/migrations/20260716120000_resource-metadata-search-index.ts
+++ b/backend/src/db/migrations/20260716120000_resource-metadata-org-id-key-index.ts
@@ -4,8 +4,6 @@ import { TableName } from "../schemas";
// serves the org-scoped secret-metadata search (dashboard /secrets-by-metadata)
const ORG_KEY_INDEX_NAME = "resource_metadata_org_id_key_idx";
-// covers the (previously unindexed) secretId FK + the search's join/correlated lookups
-const SECRET_ID_INDEX_NAME = "resource_metadata_secret_id_idx";
const MIGRATION_TIMEOUT = 60 * 60 * 1000;
const MIGRATION_LOCK_TIMEOUT = 30 * 1000;
@@ -25,7 +23,7 @@ export async function up(knex: Knex): Promise<void> {
(await knex.schema.hasColumn(TableName.ResourceMetadata, "orgId")) &&
(await knex.schema.hasColumn(TableName.ResourceMetadata, "secretId"))
) {
- // partial indexes (secret metadata only) keep the indexes small and targeted at the search.
+ // partial index (secret metadata only for where secretId is not null) keeps the index small and targeted at the search.
// "value" is intentionally excluded (up to 1020 chars would risk the btree row-size limit);
// (orgId, key) narrows enough that filtering value on the matched rows is cheap.
await knex.raw(`
@@ -33,12 +31,6 @@ export async function up(knex: Knex): Promise<void> {
ON ${TableName.ResourceMetadata} ("orgId", "key")
WHERE "secretId" IS NOT NULL
`);
-
- await knex.raw(`
- CREATE INDEX CONCURRENTLY IF NOT EXISTS "${SECRET_ID_INDEX_NAME}"
- ON ${TableName.ResourceMetadata} ("secretId")
- WHERE "secretId" IS NOT NULL
- `);
}
} finally {
await knex.raw(`SET statement_timeout = '${originalStatementTimeout}'`);
@@ -48,7 +40,6 @@ export async function up(knex: Knex): Promise<void> {
export async function down(knex: Knex): Promise<void> {
await knex.raw(`DROP INDEX CONCURRENTLY IF EXISTS "${ORG_KEY_INDEX_NAME}"`);
- await knex.raw(`DROP INDEX CONCURRENTLY IF EXISTS "${SECRET_ID_INDEX_NAME}"`);
}
const config = { transaction: false };
diff --git a/backend/src/db/migrations/20260716120001_resource-metadata-secret-id-index.ts b/backend/src/db/migrations/20260716120001_resource-metadata-secret-id-index.ts
new file mode 100644
index 0000000000..7923d6094d
--- /dev/null
+++ b/backend/src/db/migrations/20260716120001_resource-metadata-secret-id-index.ts
@@ -0,0 +1,42 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// covers the (previously unindexed) secretId FK + the search's join/correlated lookups
+const SECRET_ID_INDEX_NAME = "resource_metadata_secret_id_idx";
+
+const MIGRATION_TIMEOUT = 60 * 60 * 1000;
+const MIGRATION_LOCK_TIMEOUT = 30 * 1000;
+
+export async function up(knex: Knex): Promise<void> {
+ const stmtResult = await knex.raw("SHOW statement_timeout");
+ const originalStatementTimeout = stmtResult.rows[0].statement_timeout;
+ const lockResult = await knex.raw("SHOW lock_timeout");
+ const originalLockTimeout = lockResult.rows[0].lock_timeout;
+
+ try {
+ await knex.raw(`SET statement_timeout = ${MIGRATION_TIMEOUT}`);
+ await knex.raw(`SET lock_timeout = ${MIGRATION_LOCK_TIMEOUT}`);
+
+ if (
+ (await knex.schema.hasTable(TableName.ResourceMetadata)) &&
+ (await knex.schema.hasColumn(TableName.ResourceMetadata, "secretId"))
+ ) {
+ await knex.raw(`
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "${SECRET_ID_INDEX_NAME}"
+ ON ${TableName.ResourceMetadata} ("secretId")
+ WHERE "secretId" IS NOT NULL
+ `);
+ }
+ } finally {
+ await knex.raw(`SET statement_timeout = '${originalStatementTimeout}'`);
+ await knex.raw(`SET lock_timeout = '${originalLockTimeout}'`);
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ await knex.raw(`DROP INDEX CONCURRENTLY IF EXISTS "${SECRET_ID_INDEX_NAME}"`);
+}
+
+const config = { transaction: false };
+export { config };
diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.ts
index cd09b8b890..31da6f7b06 100644
--- a/backend/src/server/routes/v1/dashboard-router.ts
+++ b/backend/src/server/routes/v1/dashboard-router.ts
@@ -10,7 +10,6 @@ import { SecretRotationV2Schema } from "@app/ee/services/secret-rotation-v2/secr
import { DASHBOARD } from "@app/lib/api-docs";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { prefixWithSlash, removeTrailingSlash } from "@app/lib/fn";
-import { logger } from "@app/lib/logger";
import { OrderByDirection } from "@app/lib/types";
import { readLimit, secretsLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
@@ -131,8 +130,6 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
handler: async (req) => {
const rawQueryString = req.url.includes("?") ? req.url.slice(req.url.indexOf("?") + 1) : "";
const { filters, operator } = SecretMetadataSearchQuerySchema.parse(qs.parse(rawQueryString));
- logger.info(`Filters: ${JSON.stringify(filters)}`);
- logger.info(`Operator: ${operator}`);
const { projectId } = req.query;
const { secrets } = await server.services.resourceMetadata.searchSecretMetadata({