Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. 🫖 Status page with uptime monitoring & API monitoring as code 🫖 openstatus.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { eq } from "@openstatus/db";import { maintenance } from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";import { requireScope } from "../auth";import { type ServiceContext, withTransaction } from "../context";import { getMaintenanceInWorkspace } from "./internal";import { DeleteMaintenanceInput } from "./schemas";
/** Delete a maintenance row. Cascade removes `maintenances_to_page_components`. */export async function deleteMaintenance(args: { ctx: ServiceContext; input: DeleteMaintenanceInput;}): Promise<void> { const { ctx } = args; requireScope(ctx, "write"); const input = DeleteMaintenanceInput.parse(args.input);
await withTransaction(ctx, async (tx) => { const existing = await getMaintenanceInWorkspace({ tx, id: input.id, workspaceId: ctx.workspace.id, });
await tx.delete(maintenance).where(eq(maintenance.id, existing.id));
await emitAudit(tx, ctx, { action: "maintenance.delete", entityType: "maintenance", entityId: existing.id, before: existing, }); });}