# Maintenance

> Preventive maintenance plans that fall due by time or by a meter, meter readings, calibration records, and the dispatch work orders the plans open with their spare parts.

- Category: Work management
- Module: `maintenance`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/maintenance
- Page: https://bettersupabase.com/blocks/maintenance

## Install

```bash
npx better-supabase add maintenance
```

The command also installs `updated-at`, `memberships`, `permissions`, `subjects`, `dispatch`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by maintenance; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    subjects: {},
    dispatch: {},
    // Modes: "managed", "custom". The default is "managed".
    maintenance: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/maintenance`.

## Events

- `maintenance_calibration.recorded`
- `maintenance_meter_reading.recorded`
- `maintenance_plan.completed`
- `maintenance_plan.created`
- `maintenance_plan.deleted`
- `maintenance_plan.triggered`
- `maintenance_plan.updated`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [subjects](https://bettersupabase.com/blocks/subjects.md), [dispatch](https://bettersupabase.com/blocks/dispatch.md)

Works with: [assets](https://bettersupabase.com/blocks/assets.md), [inventory](https://bettersupabase.com/blocks/inventory.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md)
