mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 09:26:37 +00:00
Replace insertMany operation with upsert for backfilling trusted ips
This commit is contained in:
@@ -568,18 +568,29 @@ export const backfillTrustedIps = async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (workspaceIdsToAddTrustedIp.length === 0) return;
|
if (workspaceIdsToAddTrustedIp.length > 0) {
|
||||||
|
const operations = workspaceIdsToAddTrustedIp.map((workspaceId) => {
|
||||||
const trustedIpsToInsert = workspaceIdsToAddTrustedIp.map((workspaceId) => {
|
const update = {
|
||||||
return new TrustedIP({
|
workspace: workspaceId,
|
||||||
workspace: workspaceId,
|
ipAddress: "0.0.0.0",
|
||||||
ipAddress: "0.0.0.0",
|
type: IPType.IPV4,
|
||||||
type: IPType.IPV4,
|
prefix: 0,
|
||||||
prefix: 0,
|
isActive: true,
|
||||||
isActive: true,
|
comment: ""
|
||||||
comment: "",
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
await TrustedIP.insertMany(trustedIpsToInsert);
|
return {
|
||||||
|
updateOne: {
|
||||||
|
filter: update,
|
||||||
|
update: {
|
||||||
|
$setOnInsert: update
|
||||||
|
},
|
||||||
|
upsert: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await TrustedIP.bulkWrite(operations);
|
||||||
|
console.log("Backfill: Trusted IPs complete");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user