Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add invalid check on index creation
adilson28715ac6d73e
diff --git a/backend/src/db/migrations/20261014120000_add-secret-approval-secrets-v2-request-id-index.ts b/backend/src/db/migrations/20261014120000_add-secret-approval-secrets-v2-request-id-index.tsindex 3fae19439a..ffe96459aa 100644--- a/backend/src/db/migrations/20261014120000_add-secret-approval-secrets-v2-request-id-index.ts+++ b/backend/src/db/migrations/20261014120000_add-secret-approval-secrets-v2-request-id-index.ts@@ -26,6 +26,13 @@ export async function up(knex: Knex): Promise<void> {(await knex.schema.hasTable(TableName.SecretApprovalRequestSecretV2)) &&(await knex.schema.hasColumn(TableName.SecretApprovalRequestSecretV2, COLUMN))) {+ const invalid = await raw(+ `SELECT 1 FROM pg_class c JOIN pg_index i ON i.indexrelid = c.oid WHERE c.relname = '${INDEX_NAME}' AND NOT i.indisvalid`+ );+ if (invalid.rows.length > 0) {+ await raw(`DROP INDEX CONCURRENTLY IF EXISTS "${INDEX_NAME}"`);+ }+await raw(`CREATE INDEX CONCURRENTLY IF NOT EXISTS "${INDEX_NAME}"ON ${TableName.SecretApprovalRequestSecretV2} ("${COLUMN}")