Skip to content

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

fix(migration): guard down migration against Doppler rows breaking NOT NULL constraint

Igor Correaa7af021d8eaa
diff --git a/backend/src/db/migrations/20260330172252_rename-vault-to-external-migration-config.ts b/backend/src/db/migrations/20260330172252_rename-vault-to-external-migration-config.ts
index e67d041968..a05b1f7c17 100644
--- a/backend/src/db/migrations/20260330172252_rename-vault-to-external-migration-config.ts
+++ b/backend/src/db/migrations/20260330172252_rename-vault-to-external-migration-config.ts
@@ -34,8 +34,12 @@ export async function up(knex: Knex): Promise<void> {
export async function down(knex: Knex): Promise<void> {
if (await knex.schema.hasTable(TableName.ExternalMigrationConfig)) {
+ // Remove Doppler rows before re-applying the NOT NULL constraint on namespace
+ await knex(TableName.ExternalMigrationConfig).where("provider", "doppler").delete();
+
+ const hasProviderColumn = await knex.schema.hasColumn(TableName.ExternalMigrationConfig, "provider");
await knex.schema.alterTable(TableName.ExternalMigrationConfig, (t) => {
- t.dropColumn("provider");
+ if (hasProviderColumn) t.dropColumn("provider");
t.string("namespace").notNullable().alter();
});