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
refactor: start tokenVersion at 0 instead of 1
bernie-g6c289d267e82
diff --git a/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts b/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.tsindex d182def0ce..e3913b2e4b 100644--- a/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts+++ b/backend/src/db/migrations/20260413000001_gateway-enrollment-tokens.ts@@ -7,7 +7,7 @@ export async function up(knex: Knex): Promise<void> {// Make identityId nullable and add tokenVersion to support enrollment-token-based gatewaysawait knex.schema.alterTable(TableName.GatewayV2, (t) => {t.uuid("identityId").nullable().alter();- t.integer("tokenVersion").notNullable().defaultTo(1);+ t.integer("tokenVersion").notNullable().defaultTo(0);});if (!(await knex.schema.hasTable(TableName.GatewayEnrollmentTokens))) {diff --git a/backend/src/db/schemas/gateways-v2.ts b/backend/src/db/schemas/gateways-v2.tsindex cd1d69fd13..aa286fe587 100644--- a/backend/src/db/schemas/gateways-v2.ts+++ b/backend/src/db/schemas/gateways-v2.ts@@ -21,7 +21,7 @@ export const GatewaysV2Schema = z.object({encryptedPamSessionKey: zodBuffer.nullable().optional(),healthAlertedAt: z.date().nullable().optional(),lastHealthCheckStatus: z.string().nullable().optional(),- tokenVersion: z.number().default(1)+ tokenVersion: z.number().default(0)});export type TGatewaysV2 = z.infer<typeof GatewaysV2Schema>;diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.tsindex c59e82f736..13e39af7cb 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts@@ -1408,7 +1408,7 @@ export const gatewayV2ServiceFactory = ({gatewayId: gateway.id,orgId,authTokenType: AuthTokenType.GATEWAY_ACCESS_TOKEN,- tokenVersion: gateway.tokenVersion ?? 1+ tokenVersion: gateway.tokenVersion},appCfg.AUTH_SECRET);