Skip to content

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

fix(rate-limit): remove rate_limit analytics view before dropping table

Calvin6474d7d9ab9c
diff --git a/backend/src/db/migrations/20260123144431_add-identity-project-creation-rate-limits.ts b/backend/src/db/migrations/20260123144431_add-identity-project-creation-rate-limits.ts
index 2f449d66ac..69c5211834 100644
--- a/backend/src/db/migrations/20260123144431_add-identity-project-creation-rate-limits.ts
+++ b/backend/src/db/migrations/20260123144431_add-identity-project-creation-rate-limits.ts
@@ -3,7 +3,10 @@ import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
- const hasIdentityCreationLimitCol = await knex.schema.hasColumn(TableName.DeprecatedRateLimit, "identityCreationLimit");
+ const hasIdentityCreationLimitCol = await knex.schema.hasColumn(
+ TableName.DeprecatedRateLimit,
+ "identityCreationLimit"
+ );
const hasProjectCreationLimitCol = await knex.schema.hasColumn(TableName.DeprecatedRateLimit, "projectCreationLimit");
await knex.schema.alterTable(TableName.DeprecatedRateLimit, (t) => {
@@ -17,7 +20,10 @@ export async function up(knex: Knex): Promise<void> {
}
export async function down(knex: Knex): Promise<void> {
- const hasIdentityCreationLimitCol = await knex.schema.hasColumn(TableName.DeprecatedRateLimit, "identityCreationLimit");
+ const hasIdentityCreationLimitCol = await knex.schema.hasColumn(
+ TableName.DeprecatedRateLimit,
+ "identityCreationLimit"
+ );
const hasProjectCreationLimitCol = await knex.schema.hasColumn(TableName.DeprecatedRateLimit, "projectCreationLimit");
await knex.schema.alterTable(TableName.DeprecatedRateLimit, (t) => {
diff --git a/backend/src/db/migrations/20261009120000_drop-rate-limit.ts b/backend/src/db/migrations/20261009120000_drop-rate-limit.ts
index 2e5de92b4a..d1cae1d8e4 100644
--- a/backend/src/db/migrations/20261009120000_drop-rate-limit.ts
+++ b/backend/src/db/migrations/20261009120000_drop-rate-limit.ts
@@ -6,6 +6,9 @@ import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
export async function up(knex: Knex): Promise<void> {
const hasTable = await knex.schema.hasTable(TableName.DeprecatedRateLimit);
if (hasTable) {
+ // The analytics view is normally dropped before migrations run, but not if GENERATE_SANITIZED_SCHEMA
+ // was turned off after the view was created, and the view would block dropping the table.
+ await knex.raw(`DROP VIEW IF EXISTS analytics.${TableName.DeprecatedRateLimit}`);
await dropOnUpdateTrigger(knex, TableName.DeprecatedRateLimit);
await knex.schema.dropTable(TableName.DeprecatedRateLimit);
}
diff --git a/backend/src/db/sanitized-schema.yaml b/backend/src/db/sanitized-schema.yaml
index 1adb6e3f8d..5225a8c870 100644
--- a/backend/src/db/sanitized-schema.yaml
+++ b/backend/src/db/sanitized-schema.yaml
@@ -969,20 +969,6 @@ tables:
- defaultProduct
- secretDetectionIgnoreValues
- - name: rate_limit
- source: public.rate_limit
- columns:
- - id
- - readRateLimit
- - writeRateLimit
- - secretsRateLimit
- - authRateLimit
- - inviteUserRateLimit
- - mfaRateLimit
- - publicEndpointLimit
- - createdAt
- - updatedAt
-
- name: relays
source: public.relays
columns: