mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import DataMigrationBase from "./DataMigrationBase";
|
|
import LIMIT_MAX from "Common/Types/Database/LimitMax";
|
|
import StatusPageService from "Common/Server/Services/StatusPageService";
|
|
import StatusPage from "Common/Models/DatabaseModels/StatusPage";
|
|
|
|
export default class MoveEnableSubscribersToEnableEmailSubscribersOnStatusPage extends DataMigrationBase {
|
|
public constructor() {
|
|
super("AddPostedAtToPublicNotes");
|
|
}
|
|
|
|
public override async migrate(): Promise<void> {
|
|
// get all the users with email isVerified true.
|
|
|
|
const tempStatusPage: StatusPage = new StatusPage();
|
|
|
|
if (!tempStatusPage.getTableColumnMetadata("enableSubscribers")) {
|
|
// this column does not exist, so we can skip this migration.
|
|
return;
|
|
}
|
|
|
|
const statusPages: Array<StatusPage> = await StatusPageService.findBy({
|
|
query: {},
|
|
select: {
|
|
_id: true,
|
|
enableSubscribers: true,
|
|
},
|
|
skip: 0,
|
|
limit: LIMIT_MAX,
|
|
props: {
|
|
isRoot: true,
|
|
},
|
|
});
|
|
|
|
for (const statusPage of statusPages) {
|
|
await StatusPageService.updateOneById({
|
|
id: statusPage.id!,
|
|
data: {
|
|
enableEmailSubscribers: statusPage.enableSubscribers!,
|
|
},
|
|
props: {
|
|
isRoot: true,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
public override async rollback(): Promise<void> {
|
|
return;
|
|
}
|
|
}
|