Skip to content

Open-source status page, incident response and uptime monitoring

chore: post-maintenance visual improvements on dashboard (#869)

Maximilian Kaskebf72eb6b2b19
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
index d2d5a2196..75fd196df 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
@@ -31,7 +31,7 @@ const searchParamsSchema = z.object({
if (v === "true") return true;
if (v === "false") return false;
return undefined;
- }),
+ })
)
.optional(),
});
@@ -61,8 +61,9 @@ export default async function MonitorPage({
/>
);
- const _incidents = await api.incident.getIncidentsByWorkspace.query();
+ const _incidents = await api.incident.getIncidentsByWorkspace.query(); // TODO: filter by last 7 days
const tags = await api.monitorTag.getMonitorTagsByWorkspace.query();
+ const _maintenances = await api.maintenance.getLast7DaysByWorkspace.query();
// maybe not very efficient?
// use Suspense and Client call instead?
@@ -72,30 +73,34 @@ export default async function MonitorPage({
{
monitorId: String(monitor.id),
},
- { cache: "no-store", revalidate: 0 },
+ { cache: "no-store", revalidate: 0 }
);
const data = await tb.endpointStatusPeriod("7d")(
{
monitorId: String(monitor.id),
},
- { cache: "no-store", revalidate: 0 },
+ { cache: "no-store", revalidate: 0 }
);
const [current] = metrics?.sort((a, b) =>
- (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1,
+ (a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1
) || [undefined];
const incidents = _incidents.filter(
- (incident) => incident.monitorId === monitor.id,
+ (incident) => incident.monitorId === monitor.id
);
const tags = monitor.monitorTagsToMonitors.map(
- ({ monitorTag }) => monitorTag,
+ ({ monitorTag }) => monitorTag
);
- return { monitor, metrics: current, data, incidents, tags };
- }),
+ const maintenances = _maintenances.filter((maintenance) =>
+ maintenance.monitors.includes(monitor.id)
+ );
+
+ return { monitor, metrics: current, data, incidents, maintenances, tags };
+ })
);
return (
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
index 88dac86aa..a40adeb69 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/layout.tsx
@@ -36,13 +36,14 @@ export default async function Layout({
<StatusDotWithTooltip
active={monitor.active}
status={monitor.status}
+ maintenance={monitor.maintenance}
/>
{monitor.monitorTagsToMonitors.length > 0 ? (
<>
<span className="text-muted-foreground/50 text-xs">•</span>
<TagBadgeWithTooltip
tags={monitor.monitorTagsToMonitors.map(
- ({ monitorTag }) => monitorTag,
+ ({ monitorTag }) => monitorTag
)}
/>
</>
diff --git a/apps/web/src/app/status-page/[domain]/_components/header.tsx b/apps/web/src/app/status-page/[domain]/_components/header.tsx
index 5f533e403..9d9f25831 100644
--- a/apps/web/src/app/status-page/[domain]/_components/header.tsx
+++ b/apps/web/src/app/status-page/[domain]/_components/header.tsx
@@ -46,7 +46,6 @@ export function Header({ navigation, plan, page }: Props) {
<TabsContainer className="-mb-[14px] hidden sm:block">
{navigation.map(({ label, href, disabled, segment }) => {
const active = segment === selectedSegment;
- if (disabled) return null;
return (
<TabsLink key={segment} {...{ active, href, label, disabled }}>
{label}
diff --git a/apps/web/src/app/status-page/[domain]/_components/menu.tsx b/apps/web/src/app/status-page/[domain]/_components/menu.tsx
index 0c475123b..9f947452b 100644
--- a/apps/web/src/app/status-page/[domain]/_components/menu.tsx
+++ b/apps/web/src/app/status-page/[domain]/_components/menu.tsx
@@ -53,7 +53,6 @@ export function Menu({ navigation }: Props) {
<ul className="grid gap-1">
{navigation.map(({ href, label, segment, disabled }) => {
const active = segment === selectedSegment;
- if (disabled) return null;
return (
<li key={href} className="w-full">
<AppLink {...{ href, label, active, disabled }} />
diff --git a/apps/web/src/components/data-table/maintenance/columns.tsx b/apps/web/src/components/data-table/maintenance/columns.tsx
index 4b9958ed3..d5f12cffd 100644
--- a/apps/web/src/components/data-table/maintenance/columns.tsx
+++ b/apps/web/src/components/data-table/maintenance/columns.tsx
@@ -5,6 +5,8 @@ import type { ColumnDef } from "@tanstack/react-table";
import type { Maintenance } from "@openstatus/db/src/schema";
import { DataTableRowActions } from "./data-table-row-actions";
+import { formatDateTime } from "@/lib/utils";
+import { format } from "date-fns";
export const columns: ColumnDef<Maintenance>[] = [
{
@@ -22,6 +24,28 @@ export const columns: ColumnDef<Maintenance>[] = [
);
},
},
+ {
+ accessorKey: "from",
+ header: "Start",
+ cell: ({ row }) => {
+ return (
+ <p className="text-muted-foreground">
+ {format(row.getValue("from"), "LLL dd, y HH:mm zzzz")}
+ </p>
+ );
+ },
+ },
+ {
+ accessorKey: "to",
+ header: "End",
+ cell: ({ row }) => {
+ return (
+ <p className="text-muted-foreground">
+ {format(row.getValue("to"), "LLL dd, y HH:mm zzzz")}
+ </p>
+ );
+ },
+ },
// missing: from, to
{
id: "actions",
diff --git a/apps/web/src/components/data-table/monitor/columns.tsx b/apps/web/src/components/data-table/monitor/columns.tsx
index 819bcb642..56dcc3d59 100644
--- a/apps/web/src/components/data-table/monitor/columns.tsx
+++ b/apps/web/src/components/data-table/monitor/columns.tsx
@@ -4,7 +4,12 @@ import type { ColumnDef } from "@tanstack/react-table";
import { formatDistanceToNowStrict } from "date-fns";
import Link from "next/link";
-import type { Incident, Monitor, MonitorTag } from "@openstatus/db/src/schema";
+import type {
+ Incident,
+ Maintenance,
+ Monitor,
+ MonitorTag,
+} from "@openstatus/db/src/schema";
import type {
Monitor as MonitorTracker,
ResponseTimeMetrics,
@@ -21,6 +26,8 @@ import {
import { StatusDotWithTooltip } from "@/components/monitor/status-dot-with-tooltip";
import { TagBadgeWithTooltip } from "@/components/monitor/tag-badge-with-tooltip";
import { Bar } from "@/components/tracker/tracker";
+import { isActiveMaintenance } from "@/lib/maintenances/utils";
+
import { DataTableRowActions } from "./data-table-row-actions";
export const columns: ColumnDef<{
@@ -28,6 +35,7 @@ export const columns: ColumnDef<{
metrics?: ResponseTimeMetrics;
data?: MonitorTracker[];
incidents?: Incident[];
+ maintenances?: Maintenance[];
tags?: MonitorTag[];
}>[] = [
{
@@ -36,13 +44,18 @@ export const columns: ColumnDef<{
header: "Name",
cell: ({ row }) => {
const { active, status, name, public: _public } = row.original.monitor;
+ const maintenance = isActiveMaintenance(row.original.maintenances);
return (
<div className="flex gap-2">
<Link
href={`./monitors/${row.original.monitor.id}/overview`}
className="group flex max-w-[150px] items-center gap-2 md:max-w-[250px]"
>
- <StatusDotWithTooltip active={active} status={status} />
+ <StatusDotWithTooltip
+ active={active}
+ status={status}
+ maintenance={maintenance}
+ />
<span className="truncate group-hover:underline">{name}</span>
</Link>
{_public ? <Badge variant="secondary">public</Badge> : null}
@@ -71,7 +84,7 @@ export const columns: ColumnDef<{
// REMINDER: if one value is found, return true
// we could consider restricting it to all the values have to be found
return value.some((item) =>
- row.original.tags?.some((tag) => tag.name === item),
+ row.original.tags?.some((tag) => tag.name === item)
);
},
},
@@ -84,6 +97,7 @@ export const columns: ColumnDef<{
const tracker = new Tracker({
data: row.original.data?.slice(0, 7).reverse(),
incidents: row.original.incidents,
+ maintenances: row.original.maintenances,
});
return (
<div className="flex w-24 gap-1">
diff --git a/apps/web/src/components/data-table/status-page/columns.tsx b/apps/web/src/components/data-table/status-page/columns.tsx
index 7254b4485..b093121b2 100644
--- a/apps/web/src/components/data-table/status-page/columns.tsx
+++ b/apps/web/src/components/data-table/status-page/columns.tsx
@@ -5,7 +5,7 @@ import Image from "next/image";
import Link from "next/link";
import * as z from "zod";
-import type { Page } from "@openstatus/db/src/schema";
+import type { Maintenance, Page } from "@openstatus/db/src/schema";
import {
Badge,
Tooltip,
@@ -18,7 +18,10 @@ import { DataTableRowActions } from "./data-table-row-actions";
import { Check } from "lucide-react";
export const columns: ColumnDef<
- Page & { monitorsToPages: { monitor: { name: string } }[] }
+ Page & {
+ monitorsToPages: { monitor: { name: string } }[];
+ maintenancesToPages: Maintenance[]; // we get only the active maintenances!
+ }
>[] = [
{
accessorKey: "title",
@@ -32,6 +35,9 @@ export const columns: ColumnDef<
<span className="max-w-[125px] truncate group-hover:underline">
{row.getValue("title")}
</span>
+ {row.original.maintenancesToPages.length > 0 ? (
+ <Badge>Maintenance</Badge>
+ ) : null}
</Link>
);
},
diff --git a/apps/web/src/components/forms/maintenance/general.tsx b/apps/web/src/components/forms/maintenance/general.tsx
index 1f7f0b7b8..f25f0373c 100644
--- a/apps/web/src/components/forms/maintenance/general.tsx
+++ b/apps/web/src/components/forms/maintenance/general.tsx
@@ -17,6 +17,7 @@ import {
} from "@openstatus/ui";
import { SectionHeader } from "../shared/section-header";
+import { format } from "date-fns";
interface Props {
form: UseFormReturn<InsertMaintenance>;
@@ -101,7 +102,11 @@ export function General({ form }: Props) {
)}
/>
<FormDescription className="sm:-mt-2 col-span-full">
- The date and time when the incident took place.
+ The period{" "}
+ <span className="font-medium">
+ in local time {format(new Date(), "z")}
+ </span>{" "}
+ when the maintenance takes place.
</FormDescription>
</div>
</div>
diff --git a/apps/web/src/components/monitor/status-dot-with-tooltip.tsx b/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
index 856a77b33..7fcdc40ef 100644
--- a/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
+++ b/apps/web/src/components/monitor/status-dot-with-tooltip.tsx
@@ -10,22 +10,21 @@ import { StatusDot } from "./status-dot";
export interface StatusDotWithTooltipProps extends StatusDotProps {}
-export function StatusDotWithTooltip({
- status,
- active,
-}: StatusDotWithTooltipProps) {
+export function StatusDotWithTooltip(props: StatusDotWithTooltipProps) {
+ const { active, maintenance, status } = props;
return (
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger>
- <StatusDot {...{ status, active }} />
+ <StatusDot {...props} />
</TooltipTrigger>
<TooltipContent>
- {active
- ? status === "active"
- ? "Monitor is active"
- : "Monitor has failed"
- : "Monitor is inactive"}
+ {(() => {
+ if (!active) return "Monitor is inactive";
+ if (maintenance) return "Monitor in maintenance";
+ if (status === "error") return "Monitor has failed";
+ return "Monitor is active";
+ })()}
</TooltipContent>
</Tooltip>
</TooltipProvider>
diff --git a/apps/web/src/components/monitor/status-dot.tsx b/apps/web/src/components/monitor/status-dot.tsx
index 0f92e9ffa..de5ebdefb 100644
--- a/apps/web/src/components/monitor/status-dot.tsx
+++ b/apps/web/src/components/monitor/status-dot.tsx
@@ -1,8 +1,12 @@
import type { Monitor } from "@openstatus/db/src/schema";
-export interface StatusDotProps extends Pick<Monitor, "active" | "status"> {}
+export interface StatusDotProps {
+ active?: Monitor["active"];
+ status?: Monitor["status"];
+ maintenance?: boolean;
+}
-export function StatusDot({ active, status }: StatusDotProps) {
+export function StatusDot({ active, status, maintenance }: StatusDotProps) {
if (!active) {
return (
<span className="relative flex h-2 w-2">
@@ -10,16 +14,27 @@ export function StatusDot({ active, status }: StatusDotProps) {
</span>
);
}
+ if (maintenance) {
+ return (
+ <span className="relative flex h-2 w-2">
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-500/80 opacity-75 duration-1000" />
+ <span className="relative inline-flex h-2 w-2 rounded-full bg-blue-500" />
+ </span>
+ );
+ }
+ if (status === "error") {
+ return (
+ <span className="relative flex h-2 w-2">
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500/80 opacity-75 duration-1000" />
+ <span className="absolute inline-flex h-2 w-2 rounded-full bg-red-500" />
+ </span>
+ );
+ }
- return status === "active" ? (
+ return (
<span className="relative flex h-2 w-2">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500/80 opacity-75 duration-1000" />
<span className="relative inline-flex h-2 w-2 rounded-full bg-green-500" />
</span>
- ) : (
- <span className="relative flex h-2 w-2">
- <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500/80 opacity-75 duration-1000" />
- <span className="absolute inline-flex h-2 w-2 rounded-full bg-red-500" />
- </span>
);
}
diff --git a/apps/web/src/lib/maintenances/utils.ts b/apps/web/src/lib/maintenances/utils.ts
new file mode 100644
index 000000000..9d0f77929
--- /dev/null
+++ b/apps/web/src/lib/maintenances/utils.ts
@@ -0,0 +1,8 @@
+import type { Maintenance } from "@openstatus/db/src/schema";
+
+export function isActiveMaintenance(maintenances?: Maintenance[]) {
+ if (!maintenances) return false;
+ return maintenances.some((maintenance) => {
+ return maintenance.from <= new Date() && maintenance.to >= new Date();
+ });
+}
diff --git a/packages/api/src/router/maintenance.ts b/packages/api/src/router/maintenance.ts
index 6091a4e5a..d170dab53 100644
--- a/packages/api/src/router/maintenance.ts
+++ b/packages/api/src/router/maintenance.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
-import { and, eq, inArray } from "@openstatus/db";
+import { and, eq, gte, inArray, lte } from "@openstatus/db";
import {
insertMaintenanceSchema,
maintenance,
@@ -67,6 +67,19 @@ export const maintenanceRouter = createTRPCRouter({
.all();
return _maintenances;
}),
+ getLast7DaysByWorkspace: protectedProcedure.query(async (opts) => {
+ const _maintenances = await opts.ctx.db.query.maintenance.findMany({
+ where: and(
+ eq(maintenance.workspaceId, opts.ctx.workspace.id),
+ gte(maintenance.from, new Date(Date.now() - 7 * 24 * 60 * 60 * 1000))
+ ),
+ with: { maintenancesToMonitors: true },
+ });
+ return _maintenances.map((m) => ({
+ ...m,
+ monitors: m.maintenancesToMonitors.map((m) => m.monitorId),
+ }));
+ }),
getByPage: protectedProcedure
.input(z.object({ id: z.number() }))
.query(async (opts) => {
@@ -83,6 +96,20 @@ export const maintenanceRouter = createTRPCRouter({
// TODO:
return _maintenances;
}),
+ getActiveByWorkspace: protectedProcedure.query(async (opts) => {
+ const _maintenances = await opts.ctx.db
+ .select()
+ .from(maintenance)
+ .where(
+ and(
+ eq(maintenance.workspaceId, opts.ctx.workspace.id),
+ gte(maintenance.to, new Date()),
+ lte(maintenance.from, new Date())
+ )
+ )
+ .all();
+ return _maintenances;
+ }),
update: protectedProcedure
.input(insertMaintenanceSchema)
.mutation(async (opts) => {
diff --git a/packages/api/src/router/monitor.ts b/packages/api/src/router/monitor.ts
index dd99d94db..03d4e0c73 100644
--- a/packages/api/src/router/monitor.ts
+++ b/packages/api/src/router/monitor.ts
@@ -10,6 +10,7 @@ import {
import { and, eq, inArray, isNull, sql } from "@openstatus/db";
import {
insertMonitorSchema,
+ maintenancesToMonitors,
monitor,
monitorTag,
monitorTagsToMonitors,
@@ -18,6 +19,7 @@ import {
notification,
notificationsToMonitors,
page,
+ selectMaintenanceSchema,
selectMonitorSchema,
selectMonitorTagSchema,
selectNotificationSchema,
@@ -167,6 +169,10 @@ export const monitorRouter = createTRPCRouter({
),
with: {
monitorTagsToMonitors: { with: { monitorTag: true } },
+ maintenancesToMonitors: {
+ with: { maintenance: true },
+ where: eq(maintenancesToMonitors.monitorId, opts.input.id),
+ },
},
});
@@ -177,8 +183,16 @@ export const monitorRouter = createTRPCRouter({
monitorTag: selectMonitorTagSchema,
})
.array(),
+ maintenance: z.boolean().default(false).optional(),
})
- .safeParse(_monitor);
+ .safeParse({
+ ..._monitor,
+ maintenance: _monitor?.maintenancesToMonitors.some(
+ (item) =>
+ item.maintenance.from.getTime() <= Date.now() &&
+ item.maintenance.to.getTime() >= Date.now()
+ ),
+ });
if (!parsedMonitor.success) {
throw new TRPCError({
diff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.ts
index c8e4c8762..859d03616 100644
--- a/packages/api/src/router/page.ts
+++ b/packages/api/src/router/page.ts
@@ -1,7 +1,7 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
-import { and, eq, inArray, isNull, or, sql } from "@openstatus/db";
+import { and, eq, gte, inArray, isNull, lte, or, sql } from "@openstatus/db";
import {
incidentTable,
insertPageSchema,
@@ -213,6 +213,12 @@ export const pageRouter = createTRPCRouter({
where: and(eq(page.workspaceId, opts.ctx.workspace.id)),
with: {
monitorsToPages: { with: { monitor: true } },
+ maintenancesToPages: {
+ where: and(
+ lte(maintenance.from, new Date()),
+ gte(maintenance.to, new Date())
+ ),
+ },
},
});
return z.array(selectPageSchemaWithMonitorsRelation).parse(allPages);
diff --git a/packages/db/src/schema/maintenances/maintenance.ts b/packages/db/src/schema/maintenances/maintenance.ts
index 9ae79a9f8..8c4b54d6b 100644
--- a/packages/db/src/schema/maintenances/maintenance.ts
+++ b/packages/db/src/schema/maintenances/maintenance.ts
@@ -29,14 +29,6 @@ export const maintenance = sqliteTable("maintenance", {
),
});
-export const maintenanceRelations = relations(maintenance, ({ one, many }) => ({
- maintenancesToMonitors: many(maintenancesToMonitors),
- workspace: one(workspace, {
- fields: [maintenance.workspaceId],
- references: [workspace.id],
- }),
-}));
-
export const maintenancesToMonitors = sqliteTable(
"maintenance_to_monitor",
{
@@ -62,9 +54,21 @@ export const maintenancesToMonitorsRelations = relations(
fields: [maintenancesToMonitors.monitorId],
references: [monitor.id],
}),
- page: one(maintenance, {
+ maintenance: one(maintenance, {
fields: [maintenancesToMonitors.maintenanceId],
references: [maintenance.id],
}),
})
);
+
+export const maintenanceRelations = relations(maintenance, ({ one, many }) => ({
+ maintenancesToMonitors: many(maintenancesToMonitors),
+ page: one(page, {
+ fields: [maintenance.pageId],
+ references: [page.id],
+ }),
+ workspace: one(workspace, {
+ fields: [maintenance.workspaceId],
+ references: [workspace.id],
+ }),
+}));
diff --git a/packages/db/src/schema/monitors/monitor.ts b/packages/db/src/schema/monitors/monitor.ts
index 156f633c2..73549c49e 100644
--- a/packages/db/src/schema/monitors/monitor.ts
+++ b/packages/db/src/schema/monitors/monitor.ts
@@ -17,6 +17,7 @@ import {
monitorPeriodicity,
monitorStatus,
} from "./constants";
+import { maintenancesToMonitors } from "../maintenances";
export const monitor = sqliteTable("monitor", {
id: integer("id").primaryKey(),
@@ -46,10 +47,10 @@ export const monitor = sqliteTable("monitor", {
public: integer("public", { mode: "boolean" }).default(false),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
updatedAt: integer("updated_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
deletedAt: integer("deleted_at", { mode: "timestamp" }),
@@ -64,6 +65,7 @@ export const monitorRelation = relations(monitor, ({ one, many }) => ({
references: [workspace.id],
}),
monitorsToNotifications: many(notificationsToMonitors),
+ maintenancesToMonitors: many(maintenancesToMonitors),
}));
export const monitorsToPages = sqliteTable(
@@ -76,13 +78,13 @@ export const monitorsToPages = sqliteTable(
.notNull()
.references(() => page.id, { onDelete: "cascade" }),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
order: integer("order").default(0),
},
(t) => ({
pk: primaryKey(t.monitorId, t.pageId),
- }),
+ })
);
export const monitorsToPagesRelation = relations(
@@ -96,5 +98,5 @@ export const monitorsToPagesRelation = relations(
fields: [monitorsToPages.pageId],
references: [page.id],
}),
- }),
+ })
);
diff --git a/packages/db/src/schema/pages/page.ts b/packages/db/src/schema/pages/page.ts
index 58111a83f..be901fc11 100644
--- a/packages/db/src/schema/pages/page.ts
+++ b/packages/db/src/schema/pages/page.ts
@@ -4,6 +4,7 @@ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { monitorsToPages } from "../monitors";
import { pagesToStatusReports } from "../status_reports";
import { workspace } from "../workspaces";
+import { maintenance } from "../maintenances";
export const page = sqliteTable("page", {
id: integer("id").primaryKey(),
@@ -22,20 +23,21 @@ export const page = sqliteTable("page", {
// Password protecting the status page - no specific restriction on password
password: text("password", { length: 256 }),
passwordProtected: integer("password_protected", { mode: "boolean" }).default(
- false,
+ false
),
createdAt: integer("created_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
updatedAt: integer("updated_at", { mode: "timestamp" }).default(
- sql`(strftime('%s', 'now'))`,
+ sql`(strftime('%s', 'now'))`
),
});
export const pageRelations = relations(page, ({ many, one }) => ({
monitorsToPages: many(monitorsToPages),
pagesToStatusReports: many(pagesToStatusReports),
+ maintenancesToPages: many(maintenance),
workspace: one(workspace, {
fields: [page.workspaceId],
references: [workspace.id],
diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.ts
index 6200a90d3..54f3722ee 100644
--- a/packages/db/src/schema/shared.ts
+++ b/packages/db/src/schema/shared.ts
@@ -61,6 +61,7 @@ export const selectPageSchemaWithMonitorsRelation = selectPageSchema.extend({
monitor: selectMonitorSchema,
})
),
+ maintenancesToPages: selectMaintenanceSchema.array().default([]),
});
export const selectPublicPageSchemaWithRelation = selectPageSchema