Skip to content

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

fix migratio

adilsonf379b8af71ec
diff --git a/backend/src/db/migrations/20261002193922_secret-change-requests-validate-and-index.ts b/backend/src/db/migrations/20261002193922_secret-change-requests-validate-and-index.ts
index fa4671e687..32e12f9b21 100644
--- a/backend/src/db/migrations/20261002193922_secret-change-requests-validate-and-index.ts
+++ b/backend/src/db/migrations/20261002193922_secret-change-requests-validate-and-index.ts
@@ -10,37 +10,42 @@ const MIGRATION_TIMEOUT = 60 * 60 * 1000; // 60 minutes
const MIGRATION_LOCK_TIMEOUT = 30 * 1000; // 30 seconds
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;
+ const connection = await knex.client.acquireConnection();
+ const raw = (sql: string, bindings: readonly Knex.RawBinding[] = []) =>
+ knex.raw(sql, bindings).connection(connection);
try {
- await knex.raw(`SET statement_timeout = ${MIGRATION_TIMEOUT}`);
- await knex.raw(`SET lock_timeout = ${MIGRATION_LOCK_TIMEOUT}`);
-
- if (
- (await knex.schema.hasTable(TableName.SecretApprovalRequestSecretV2)) &&
- (await knex.schema.hasColumn(TableName.SecretApprovalRequestSecretV2, COLUMN))
- ) {
- await knex.raw(`ALTER TABLE ?? VALIDATE CONSTRAINT ??`, [
- TableName.SecretApprovalRequestSecretV2,
- REQUEST_XOR_CHANGE_CHECK
- ]);
- await knex.raw(`ALTER TABLE ?? VALIDATE CONSTRAINT ??`, [
- TableName.SecretApprovalRequestSecretV2,
- SECRET_CHANGE_FK
- ]);
-
- await knex.raw(`
- CREATE INDEX CONCURRENTLY IF NOT EXISTS "${INDEX_NAME}"
- ON ${TableName.SecretApprovalRequestSecretV2} ("${COLUMN}")
- WHERE "${COLUMN}" IS NOT NULL
- `);
+ const stmtResult = await raw("SHOW statement_timeout");
+ const originalStatementTimeout = stmtResult.rows[0].statement_timeout as string;
+ const lockResult = await raw("SHOW lock_timeout");
+ const originalLockTimeout = lockResult.rows[0].lock_timeout as string;
+
+ try {
+ await raw(`SET statement_timeout = ${MIGRATION_TIMEOUT}`);
+ await raw(`SET lock_timeout = ${MIGRATION_LOCK_TIMEOUT}`);
+
+ if (
+ (await knex.schema.hasTable(TableName.SecretApprovalRequestSecretV2)) &&
+ (await knex.schema.hasColumn(TableName.SecretApprovalRequestSecretV2, COLUMN))
+ ) {
+ await raw(`ALTER TABLE ?? VALIDATE CONSTRAINT ??`, [
+ TableName.SecretApprovalRequestSecretV2,
+ REQUEST_XOR_CHANGE_CHECK
+ ]);
+ await raw(`ALTER TABLE ?? VALIDATE CONSTRAINT ??`, [TableName.SecretApprovalRequestSecretV2, SECRET_CHANGE_FK]);
+
+ await raw(`
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "${INDEX_NAME}"
+ ON ${TableName.SecretApprovalRequestSecretV2} ("${COLUMN}")
+ WHERE "${COLUMN}" IS NOT NULL
+ `);
+ }
+ } finally {
+ await raw(`SET statement_timeout = '${originalStatementTimeout}'`);
+ await raw(`SET lock_timeout = '${originalLockTimeout}'`);
}
} finally {
- await knex.raw(`SET statement_timeout = '${originalStatementTimeout}'`);
- await knex.raw(`SET lock_timeout = '${originalLockTimeout}'`);
+ await knex.client.releaseConnection(connection);
}
}
diff --git a/backend/src/ee/routes/v2/secret-approval-policy-router.ts b/backend/src/ee/routes/v2/secret-approval-policy-router.ts
index 942796614a..954f21bdd9 100644
--- a/backend/src/ee/routes/v2/secret-approval-policy-router.ts
+++ b/backend/src/ee/routes/v2/secret-approval-policy-router.ts
@@ -68,7 +68,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const approval = await server.services.secretChangePolicyBridge.createSecretChangePolicy({
+ const approval = await server.services.secretApprovalPolicy.createSecretApprovalPolicy({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,