Skip to content

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

fix: resolved the migration error

=3e22c7c12dc1
diff --git a/backend/src/db/migrations/20260116175537_encrypted-resource-metadata.ts b/backend/src/db/migrations/20260116175537_encrypted-resource-metadata.ts
index 649d177b22..e99ab49e0d 100644
--- a/backend/src/db/migrations/20260116175537_encrypted-resource-metadata.ts
+++ b/backend/src/db/migrations/20260116175537_encrypted-resource-metadata.ts
@@ -12,11 +12,14 @@ export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable(TableName.ResourceMetadata, (t) => {
if (!hasEncryptedValueColumn) t.binary("encryptedValue").nullable();
if (hasValueColumn) t.string("value", 1020).nullable().alter();
- t.check(
- `(value IS NOT NULL AND "encryptedValue" IS NULL) OR (value IS NULL AND "encryptedValue" IS NOT NULL)`,
- [],
- "chk_value_or_encrypted_value"
- );
+ // if no encryptedValue column, means the column is created now, so we need to add the check constraint
+ if (!hasEncryptedValueColumn) {
+ t.check(
+ `(value IS NOT NULL AND "encryptedValue" IS NULL) OR (value IS NULL AND "encryptedValue" IS NOT NULL)`,
+ [],
+ "chk_value_or_encrypted_value"
+ );
+ }
});
}