mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import DataMigrationBase from "./DataMigrationBase";
|
|
import LIMIT_MAX from "Common/Types/Database/LimitMax";
|
|
import MonitorType from "Common/Types/Monitor/MonitorType";
|
|
import MonitorService from "Common/Server/Services/MonitorService";
|
|
import Monitor from "Common/Models/DatabaseModels/Monitor";
|
|
|
|
export default class AddSecretKeyToIncomingRequestMonitor extends DataMigrationBase {
|
|
public constructor() {
|
|
super("AddSecretKeyToIncomingRequestMonitor");
|
|
}
|
|
|
|
public override async migrate(): Promise<void> {
|
|
// get all the users with email isVerified true.
|
|
|
|
const monitors: Array<Monitor> = await MonitorService.findBy({
|
|
query: {
|
|
monitorType: MonitorType.IncomingRequest,
|
|
},
|
|
select: {
|
|
_id: true,
|
|
incomingRequestSecretKey: true,
|
|
},
|
|
skip: 0,
|
|
limit: LIMIT_MAX,
|
|
props: {
|
|
isRoot: true,
|
|
},
|
|
});
|
|
|
|
for (const monitor of monitors) {
|
|
if (!monitor.incomingRequestSecretKey) {
|
|
await MonitorService.updateOneById({
|
|
id: monitor.id!,
|
|
data: {
|
|
incomingRequestSecretKey: monitor.id!, //same as id for backward compatibility
|
|
},
|
|
props: {
|
|
isRoot: true,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public override async rollback(): Promise<void> {
|
|
return;
|
|
}
|
|
}
|