Add support for recurring maintenance tasks that automatically create issues for machines on a schedule (e.g., 'Clean playfield' every month).
Requirements
- Recurring Schedules: Admins should be able to define maintenance tasks that repeat at set intervals (days, weeks, months).
- Auto-Issue Creation: The system should automatically generate a new issue when a schedule is due.
- Admin UI: A management interface for admins to create, edit, pause, or delete maintenance schedules.
- Traceability: Link auto-generated issues back to their schedule for history tracking.
Proposed Data Model
New table: maintenance_schedules
id: UUID (PK)
machine_initials: Text (FK to machines)
title: Text (Issue title)
description: Text (Issue description)
interval_type: Enum ('days', 'weeks', 'months')
interval_value: Integer
next_run_at: Timestamp
last_run_at: Timestamp
is_active: Boolean
severity: Enum (defaults to 'minor')
priority: Enum (defaults to 'low')
Technical Implementation
- Database: Add
maintenance_schedules table via Drizzle migration.
- Scheduling Engine:
- Option 1 (Recommended): Use Vercel Cron Jobs to hit a secure internal API route (
/api/cron/maintenance) daily.
- Option 2: Use Supabase pg_cron to run a stored procedure.
- Using Vercel Cron allows us to reuse the existing
createIssue logic in src/services/issues.ts, including all timeline and notification side-effects.
- Service Logic: Create a new service (
src/services/maintenance.ts) to handle checking due schedules and triggering issue creation.
Relevant Files
src/server/db/schema.ts: Define the new table.
src/services/issues.ts: Reuse for issue creation.
src/app/(app)/admin/maintenance/page.tsx: New admin UI page.
Add support for recurring maintenance tasks that automatically create issues for machines on a schedule (e.g., 'Clean playfield' every month).
Requirements
Proposed Data Model
New table:
maintenance_schedulesid: UUID (PK)machine_initials: Text (FK to machines)title: Text (Issue title)description: Text (Issue description)interval_type: Enum ('days', 'weeks', 'months')interval_value: Integernext_run_at: Timestamplast_run_at: Timestampis_active: Booleanseverity: Enum (defaults to 'minor')priority: Enum (defaults to 'low')Technical Implementation
maintenance_schedulestable via Drizzle migration./api/cron/maintenance) daily.createIssuelogic insrc/services/issues.ts, including all timeline and notification side-effects.src/services/maintenance.ts) to handle checking due schedules and triggering issue creation.Relevant Files
src/server/db/schema.ts: Define the new table.src/services/issues.ts: Reuse for issue creation.src/app/(app)/admin/maintenance/page.tsx: New admin UI page.