mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
remove the use of aggregation for documentDB compatibility
This commit is contained in:
@@ -540,20 +540,26 @@ export const backfillIntegration = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const backfillServiceTokenMultiScope = async () => {
|
export const backfillServiceTokenMultiScope = async () => {
|
||||||
await ServiceTokenData.updateMany(
|
const documentsToUpdate = await ServiceTokenData.find({ scopes: { $exists: false } });
|
||||||
{
|
|
||||||
scopes: {
|
for (const doc of documentsToUpdate) {
|
||||||
$exists: false
|
// Cast doc to any to bypass TypeScript's type checks
|
||||||
}
|
const anyDoc = doc as any;
|
||||||
},
|
|
||||||
[
|
const environment = anyDoc.environment;
|
||||||
{
|
const secretPath = anyDoc.secretPath;
|
||||||
$set: {
|
|
||||||
scopes: [{ environment: "$environment", secretPath: "$secretPath" }]
|
if (environment && secretPath) {
|
||||||
|
const updatedScopes = [
|
||||||
|
{
|
||||||
|
environment: environment,
|
||||||
|
secretPath: secretPath
|
||||||
}
|
}
|
||||||
}
|
];
|
||||||
]
|
|
||||||
);
|
await ServiceTokenData.updateOne({ _id: doc._id }, { $set: { scopes: updatedScopes } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Migration: Service token migration v2 complete");
|
console.log("Migration: Service token migration v2 complete");
|
||||||
};
|
};
|
||||||
@@ -649,24 +655,25 @@ export const backfillUserAuthMethods = async () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await User.updateMany(
|
|
||||||
{
|
const documentsToUpdate = await User.find({
|
||||||
authProvider: {
|
authProvider: { $exists: true },
|
||||||
$exists: true
|
authMethods: { $exists: false }
|
||||||
},
|
});
|
||||||
authMethods: {
|
|
||||||
$exists: false
|
for (const doc of documentsToUpdate) {
|
||||||
}
|
// Cast doc to any to bypass TypeScript's type checks
|
||||||
},
|
const anyDoc = doc as any;
|
||||||
[
|
|
||||||
{
|
const authProvider = anyDoc.authProvider;
|
||||||
$set: {
|
const authMethods = [authProvider];
|
||||||
authMethods: ["$authProvider"]
|
|
||||||
|
await User.updateOne(
|
||||||
|
{ _id: doc._id },
|
||||||
|
{
|
||||||
|
$set: { authMethods: authMethods },
|
||||||
|
$unset: { authProvider: 1, authId: 1 }
|
||||||
}
|
}
|
||||||
},
|
);
|
||||||
{
|
}
|
||||||
$unset: ["authProvider", "authId"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user